PHP scripting tag always starts with <?php and ends with ?>. PHP scripting tag can be use anywhere in the document.
There are four sets of tags which can be used to denote blocks of PHP code. Of these, only two (<?php. . .?> and <script language="php">. . .</script>) are always available; the others can be turned on or off from the php.ini configuration file. While the short-form tags and ASP-style tags may be convenient, they are not as portable as the longer versions. Also, if you intend to embed PHP code in XML or XHTML, you will need to use the <?php. . .?> form to conform to the XML.
To activate recognition for short tags, you must make sure that the short_open_tag switch is set to On in php.ini:
short_open_tag = On;
Short tags are enabled by default, so you only need to edit php.ini if you want to disable them.
To activate recognition for the ASP style tags, you must enable the asp_tags setting:
asp_tags = On;
After you have edited php.ini, you should be able to use any of the four styles in your scripts. This is largely a matter of preference, although if you intend to include XML in your script, you should disable the short tags (<? ?>) and work with the standard tags (<?php ?>).
The character sequence <? tells an XML parser to expect a processing instruction and is therefore frequently included in XML documents. If you include XML in your script and have short tags enabled, the PHP engine is likely to confuse XML processing instructions and PHP start tags. Disable short tags if you intend to incorporate XML in your document.
You can use any of the four PHP start and end tags that you have seen:
1.) <? echo("if you want to serve XHTML or XML documents, do like this\n"); ?>
2.) <?php echo("this is the simplest, an SGML processing instruction\n""); ?>
3.) <% echo("Hello Web!"); %>
4.) <SCRIPT LANGUAGE="php">
echo("some editors (like FrontPage) don't like processing instructions!");
Instructions are separated the same as in C or Perl - terminate each statement with a semicolon.
The closing tag (?>) also implies the end of the statement, so the following are equivalent:
PHP supports 'C', 'C++' and Unix shell-style comments.
The "one-line" comment styles actually only comment to the end of the line or the current block of PHP code, whichever comes first.
Variables in PHP are represented by a dollar ($) sign followed by the name of the variable. The variable name is case-sensitive.
Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
?Computer Science is no more about computers than astronomy is about telescopes.
?Computers must be male. As soon as you commit to one you realize that if you had waited a little longer, you could have obtained a better model. In order to get their attention, you have to turn them on. Big power surges knock them out for the rest of th