Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function inside conditional?

Status
Not open for further replies.

alphacooler

Programmer
Aug 29, 2005
73
US
When one uses a function inside a conditional like:
if(move_uploaded_file($file_tmp, "$rand_name.$file_ext")) what exactly happens?

Does the function run and if it is sucessful everything inside the conditional runs?

If so, would this construct only work for functions that return true or false?

Thanks so much.
 
Functions like those return either True on a successfull run or false if something went wrong.

The conditional checks for that result.

So assuming the function is able to complete successfully
the conditional would be checking something like this:

if([blue]true[/blue]){
//do something;
}

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
If the function returns nonzero or a string, the condition is true.

If it returns zero or an empty string, the condition is considered false.
 
Okay, so this will actually tell move_uploaded_file to run?
 
Yes it will.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top