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 -

 

 

 

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.)

Edited by mac_gyver
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.