This is more for future readers on the same subject -
PHP is quite sensitive to its initiation of code and totally ignorant to the actual code contained inside its initiation blocks, here are some samples -
It is always good to get into the habit of breaking your lines down with white-space to prevent what happened here when breaking in and out of php code blocks
<?PHP
}
else
{
?>
Some more info on different options when breaking in and out of blocks -
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.
Short-open (SGML-style) tags
Short or short-open tags look like this −
<?...?>
Short tags are, as one might expect, the shortest option You must do one of two things to enable PHP to recognize the tags −
Choose the --enable-short-tags configuration option when you're building PHP.
Set the short_open_tag setting in your php.ini file to on. This option must be disabled to parse XML with PHP because the same syntax is used for XML tags.
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;
$four <tab>=<tab2<tab>+<tab>2 ;
$four =
2+
2;
Braces make blocks
Although statements cannot be combined like expressions, you can always put a sequence of statements anywhere a statement can go by enclosing them in a set of curly braces.
Here both statements are equivalent −
if (3 == 2 + 1)
print("Good - I haven't totally lost my mind.<br>");
if (3 == 2 + 1) {
print("Good - I haven't totally");
print("lost my mind.<br>");
}
I hope this will help future readers on some basics.