Originally Posted by Kanaflloric
I didn't know i could insert a <?php> tag inside a <script> tag...!
Thus, when you do things in PHP you commonly are doing it in order to create the page that you present to the user. The page you create is created on the server and shipped to the client, which is the computer the user is at.
Since you are creating the page to ship, you can create anything you want. The HTML tags mean nothing to PHP; they are just text to be manipulated.
Any time you insert a <?php ?> tag, you are telling the server to execute the code found between the opening and closing tags. Anything that is outside the PHP tags is not executed, merely shipped to the output. So, for instance, if I had the HTML string that went like this:
[HTML]<p>Ship this string of text with this <a href="very cool link">cool link</a> to the client</p>[/HTML]
I could do it with a mixture of PHP and HTML like this, for instance:
<p>Ship this string of text with this <a href="very c<?php echo $myvar;?>l link</a> to the client</p>
Which would give me the exact same display on the client's machine. Now, granting that this is a trivial example, it is indicative.