samoi Posted October 23, 2009 Share Posted October 23, 2009 Hello guys, sorry for bothering! I have some questions about PHP! Now so many times I see something like! <?php @preg_replace($pat, $rep, $str); // what does the *@* [AT] sign means in front of the function or include function? // also sometimes I see the question mark! *?* $question_mark = $samoi ? 0:1 // I don't know if this syntax is correct, but I want to explain where I usually see it! ?> Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/178766-solved-general-questions-about-php/ Share on other sites More sharing options...
severndigital Posted October 23, 2009 Share Posted October 23, 2009 @ operator good explanation here .. http://thesmithfam.org/blog/2006/05/07/php-the-operator/ single line if statement $question_mark = $samoi == 'Yes' ? 0 : 1; //is the same as if($samoi == 'Yes'){ $question_mark = 0; }else{ $question_mark = 1; } Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/178766-solved-general-questions-about-php/#findComment-943007 Share on other sites More sharing options...
Maq Posted October 23, 2009 Share Posted October 23, 2009 The ampersand suppresses error messages for that particular line. Your second question can be answered here: http://php.net/manual/en/language.operators.comparison.php (search for ternary operator). Quote Link to comment https://forums.phpfreaks.com/topic/178766-solved-general-questions-about-php/#findComment-943009 Share on other sites More sharing options...
samoi Posted October 23, 2009 Author Share Posted October 23, 2009 Thank you very much guys! that helps a lot! I really appreciate it! Quote Link to comment https://forums.phpfreaks.com/topic/178766-solved-general-questions-about-php/#findComment-943019 Share on other sites More sharing options...
salathe Posted October 23, 2009 Share Posted October 23, 2009 Just because it's helpful to know terminology (e.g. to aid further research): @ is the error control operator (or error suppression operator, manual) ?: is the ternary operator (manual) Quote Link to comment https://forums.phpfreaks.com/topic/178766-solved-general-questions-about-php/#findComment-943077 Share on other sites More sharing options...
cags Posted October 24, 2009 Share Posted October 24, 2009 The ampersand suppresses error messages for that particular line. Unless that is some alternate method I've never heard of I don't think you meant ampersand which is & and is used for signalling byRef variables. I'm sure Maq is aware of that, but thought I'd point it out for anybody else who reads the thread like me and becomes a little puzzled. Quote Link to comment https://forums.phpfreaks.com/topic/178766-solved-general-questions-about-php/#findComment-943469 Share on other sites More sharing options...
Maq Posted October 25, 2009 Share Posted October 25, 2009 The ampersand suppresses error messages for that particular line. Unless that is some alternate method I've never heard of I don't think you meant ampersand which is & and is used for signalling byRef variables. I'm sure Maq is aware of that, but thought I'd point it out for anybody else who reads the thread like me and becomes a little puzzled. Oops, yeah good catch. I meant '@' not '&'. Quote Link to comment https://forums.phpfreaks.com/topic/178766-solved-general-questions-about-php/#findComment-944061 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.