View Single Post
Old 07-01-2008, 05:01 PM   #31 (permalink)
delayedinsanity
The Gregarious
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Cana'derr
Posts: 653
Thanks: 24
delayedinsanity is on a distinguished road
Default

Tanax: In his copy of the code there is a reason to use it, because he doesn't run any checks to make sure that it's an integer, so they could very well try and insert malicious data. In mine it's casted to an integer so no it's not needed, and I omitted it.

Also, braces can be used in a couple different ways in PHP without it having to be part of a template engine. Some people will use them to further differentiate a variable within a block structure, as opposed to string concatenation, like so;

PHP Code:
$canidae 'fox';
$canis 'dog';
$szString "The quick brown {$canidae} jumps over the lazy {$canis}"
You could even use them to group a block of code if you want some more visual organization;

PHP Code:
header("Content-type: text/plain");

echo 
'Hello, world!';
echo 
"\n\n";

{
    
// This block is executed like normal code, but it's between braces so I can
    // spot it quicker when debugging.
    
$hello 'Hello';
    
$comma ', ';
    
$world 'world!';
    
$var 'world';

    echo 
$hello."{$comma}${$var}";

Codefreek: You used the if conditional without blocking out any code for it with curly braces. So it's not affecting the entirety of the script the way you want it to.

You may want to take a look at PHP: if - Manual to find out what's actually happening when you omit the curly braces after an if statement. I would also suggest considering where exactly you want the if statement to be. Do you want the form displayed whether or not a post has been made? Do you want it to attempt to login the user based on whether or not there's been a post?
-m

Last edited by delayedinsanity : 07-02-2008 at 03:52 PM.
delayedinsanity is offline  
Reply With Quote
The Following User Says Thank You to delayedinsanity For This Useful Post:
codefreek (07-01-2008)