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? Link to comment https://forums.phpfreaks.com/topic/17032-the-and-thing/ 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. Link to comment https://forums.phpfreaks.com/topic/17032-the-and-thing/#findComment-71882 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] Link to comment https://forums.phpfreaks.com/topic/17032-the-and-thing/#findComment-71884 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. Link to comment https://forums.phpfreaks.com/topic/17032-the-and-thing/#findComment-71885 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.