alexruimy Posted August 9, 2006 Share Posted August 9, 2006 I have code that looks like this:[hr][code=php:0]$result = move_uploaded_file($temp_name, $file_path); if (!chmod($file_path,0777)) $message = "change permission to 777 failed."; else $message = ($result)?"$file_name uploaded successfully." : "Something is wrong with uploading a file.";[/code][hr]Just wondering what the ($result)? part is. My guess is that it's equivalent to the following:[hr][code=php:0]if ($result){$message = "$file_name uploaded successfully.";}else {$message = "Something is wrong with uploading a file."};[/code][hr]Am I on the right track? Can someone elaborate for me as to what this is? Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 9, 2006 Share Posted August 9, 2006 You're right. It's using the ternary operator. Think of it as an "if then else" construct. Quote Link to comment Share on other sites More sharing options...
effigy Posted August 9, 2006 Share Posted August 9, 2006 [url=http://us3.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary]Manual...[/url] Quote Link to comment Share on other sites More sharing options...
alexruimy Posted August 9, 2006 Author Share Posted August 9, 2006 Thanks both for the quick replies.I would've tried to look it up but I wasn't sure of what to call it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.