View Single Post
Old 04-12-2011, 10:11 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
I can definitely tell this was converted from a vB style language.
PHP is a C based language, the syntax you have isn't correct. Anytime you make a comparison, you must use ==, as = in PHP is an assignment operator.
The other thing is the lack of braces. PHP allows non-braced branches, but will only apply for the next processing instruction or contained branch. Use full braces always to prevent confusion or ambiguity especially while reading. Alternatively (though I don't actually recommend this since PHP should reflect a C based language), you may use the alternative syntax in PHP which will more closely resemble the ASP code (though the comparisons will not be changeable).

Next, variables in PHP are case sensitive: $_SESSION is not the same as $_Session. The array accessing is correct, you should always write associative indexing in strings, though I will suggest to always use single quotations when using a constant string since its faster than double quotations which require parsing; however, $varname($offset) is not actually an array access, it is a variable function (asp may have them called under delegates), which isn't what you want.

Since PHP is datatype weak, you needn't actually check a resulting boolean in a branch if you don't want to. if ($var == true) is the same as if ($var), assuming $var is a boolean.

Finally, you must use session_start(), preferably at the start of every PHP page you intend to use sessions on.
__________________
PHP Code:
header('HTTP/1.1 420 Enhance Your Calm'); 
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Elsean (04-13-2011)