Jump to content

if ($_FILES['creature_image[error]']=0)//proper file uploaded checker


Q695

Recommended Posts

i'm not sure what previous time you are referring to, but for the line of code in this thread, DavidAM told you in your previous thread that one equal sign means that you are making an ASSIGNMENT, not a comparison -

 

 

 

  On 5/1/2013 at 6:14 PM, DavidAM said:

1) A single equals-sign is ASSIGNMENT, it takes two to COMPARE:

 

an argument can be made that you need === (three equal signs, a value and type match) for this line of code, since your image uploader script isn't testing if the $_FILES array is even set/not-empty. when $_FILES is empty due to an error or an upload form has not been submitted (your code isn't testing if any form was submitted), an empty $_FILES array will match a zero using two == signs. using three === (a value and type check), will only be successful if the $_FILES array is not empty and the ['error'] is a zero value.

 


FYI, why you need to learn the meaning of the code -

 

one = sign is an assignment operator i.e $var = some_value;. when used in a conditional test - if($var = some_value) ... while($var = some_value) the assignment is made and the value that was assigned is used in the conditional test.

 

two == signs is an equal value test (the types can be different i.e null/empty is == to a 0.)

 

three === signs is an exact value test (the value and types must be the same i.e. null/empty is not === 0.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.