I can't tell where exactly you can apply this knowledge or what may call for it. Am compelled to write on this subject so here we are.
Javascript basically is executed by the client's (your visitor's) machine (i.e browser). PHP on the other hand is parsed by PHP server; then rendered onto the browser. With this basic introduction, I guess we are good to go.
The code snippet below shows a mathematical operation performed within the open and closing braces of our PHP tag.
<?php echo "<script> var num1,num2,ans; num1 = 3; num2 = 4; ans = num1 + num2; alert(ans); </script>"; ?>This may not mean much to you right now but when you think about what you can do with it, you will know its worth. Take note of the double quotation mark immediately after the echo statement. The closing quotation mark for that comes after the greater than sign (>)in the closing tag for script. Whatsoever is between the open script and the closing script is what will be executed by the client's machine as our Javascript. In our case, an alert box will pop-up with the value 7.
0 comments:
Post a Comment