Re: Error: unexpected T_ELSE on line 14...?
| From: | Dennis Gearon | Date: | Mon, 19 Jul 2004 06:29:30 +0000 |
| Subject: | Re: Error: unexpected T_ELSE on line 14...? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-190980@lists.php.net to get a copy of this message | ||
There is a book/CD by 'Stroup' called 'More effective c++'. VERY excellent book. It give someting like 54 specific technicques to employ that save LOTS of time for a C++programmer.
One of the ones from that book, applies here:
DON'T write if ( variable ==/= constant){;}
INSTEAD write if( constant==/= variable){;}
Why, I was waiting for you to ask that question.
If you accidentally write the assignment operator '=' instead of '==/=', the first case does an assignment, and if the constant is not 0 or unset, the statment will always be true. In the second case, the interpreter/compiler will error out with the fact that you can't assign to a constant.
So do this:
$var_to_test = FALSE;
if( TRUE = $var_to_test){;}
if($var_to_test = TRUE ){;}
if( TRUE == $var_to_test){;}
if($var_to_test == TRUE ){;}
and see what happens.
<quote ------------------------------------------------------->
"Rodrigo Castro Hernandez" <roche@breakbone.org> wrote:
Hi,
You have two problems in these line:
Harlequin said:
1. The obvious ";" at the end of the line. 2. $_SESSION["Authorised"]="Yes" it's different to write: $_SESSION["Authorised"]=="Yes" Cheers,if ($_SESSION["Authorised"]="Yes");