Escaping to PHP
The PHP parsing engine needs a way to differentiate PHP code from other elements in the page. The mechanism for doing so is known as 'escaping to PHP'. There are four ways to do this −
Canonical PHP tags
The most universally effective PHP tag style is −
<?php...?>
If you use this style, you can be positive that your tags will always be correctly interpreted.
HTML script tags
HTML script tags look like this −
<script language = "PHP">...</script>
PHP is whitespace insensitive
Whitespace is the stuff you type that is typically invisible on the screen, including spaces, tabs, and carriage returns (end-of-line characters).PHP whitespace insensitive means that it almost never matters how many whitespace characters you have in a row.one whitespace character is the same as many such characters.For example, each of the following PHP statements that assigns the sum of 2 + 2 to the variable $four is equivalent −$four = 2 + 2; // single spaces $four <tab>=<tab2<tab>+<tab>2 ; // spaces and tabs $four = 2+ 2; // multiple linesPHP is case sensitive
<html> <body> <?php $capital = 67; print("Variable capital is $capital<br>"); print("Variable CaPiTaL is $CaPiTaL<br>"); ?> </body> </html>This will produce the following result −Variable capital is 67 Variable CaPiTaL is
Comments
Post a Comment