Reputation: 23379
When I do something like this:
$query = mysql_query("INSERT INTO something (something) VALUES('".$something."')");
if($query){
//do stuff
}
or
$mailstuff = mail($to,$subject,$message,$headers);
if($mailstuff){
//do stuff
}
Which part of the code actually executes the function? The if
or the declaration? References appreciated.
Thanks
Upvotes: 1
Views: 61
Reputation: 7353
$mailstuff = mail($to,$subject,$message,$headers);
if($mailstuff) {
//do stuff
}
Here is what will be done (in the correct order) :
mail($to,$subject,$message,$headers)
mail
function has returned something. This something is assigned to $mailstuff
.if
statement will check if the something in $mailstuff
is somewhat equal to true
Please not that contrary to what you suggest in your comment, the server will parse all the code before actually executing it.
Upvotes: 1
Reputation: 157324
Explanation in the code...
$mailstuff = mail($to,$subject,$message,$headers);
^-----------------------------------^
/* This part executes the function */
if($mailstuff) {
^----------^
/* Condition Here Checks whether the function is successfully executed */
//do stuff
}
Upvotes: 4