php - What does $var = value actually return? -


this seems mysterious part of php me, , wondering if clarify because manual doesn't seem include (or couldn't find anywhere).

what of these things return?

if($c = mysql_connect($host, $user, $pass)){  echo 'success'; }else{  echo 'failure'; } 

would echo 'success' because $c assigned true or false? i'm wondering if can or if have define $c on previous line.

thanks.

it mentioned in assignment operators:

the value of assignment expression value assigned. is, value of "$a = 3" 3.

so $c = ... result in true if true assigned $c , in false if false assigned.

that reason why iterating on query results

while(($row = mysql_fetch_array(...))) 

works.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -