sasori Posted August 9, 2008 Share Posted August 9, 2008 please help me guys, i don't know how to use the ternary operator in my code ??? <?php /** * @author rmbapc * @copyright 2008 */ require_once('emailer.class.php'); require_once('extendedmailer.class.php'); require_once('htmlemailer.class.php'); $emailer = new emailer('[email protected]'); $extendedemailer = new ExtendedEmailer(); $htmlemailer = new HtmlEmailer('[email protected]'); if($extendedemailer instanceof emailer)? echo "extended is dereived from emailer":"not derived from";//not working help please /*echo "Extended Emailer is derived from Emailer.<br/>"; if($htmlemailer instanceof emailer) echo "HTML Emailer is also derived from Emailer.<br/>"; if($emailer instanceof htmlEmailer) echo "Emailer is derived from HTMLEmailer<br/>"; if($htmlemailer instanceof ExtendedEmailer) echo "HTML Emailer is Derived from Emailer<br/>"; */ ?> Link to comment https://forums.phpfreaks.com/topic/118862-solved-ternary-operator-help/ Share on other sites More sharing options...
awpti Posted August 9, 2008 Share Posted August 9, 2008 There are some situations where a ternary operator doesn't work. Your syntax is fine. My guess is that this is one of those situations. Link to comment https://forums.phpfreaks.com/topic/118862-solved-ternary-operator-help/#findComment-612102 Share on other sites More sharing options...
DarkWater Posted August 9, 2008 Share Posted August 9, 2008 Remove the if...Just do: echo (($extendedemailer instanceof emailer) ? "extended is derived from emailer":"not derived from" Link to comment https://forums.phpfreaks.com/topic/118862-solved-ternary-operator-help/#findComment-612106 Share on other sites More sharing options...
sasori Posted August 9, 2008 Author Share Posted August 9, 2008 Remove the if...Just do: echo (($extendedemailer instanceof emailer) ? "extended is derived from emailer":"not derived from" daemn..it worked.. thanks sir Link to comment https://forums.phpfreaks.com/topic/118862-solved-ternary-operator-help/#findComment-612120 Share on other sites More sharing options...
DarkWater Posted August 9, 2008 Share Posted August 9, 2008 No problem. Link to comment https://forums.phpfreaks.com/topic/118862-solved-ternary-operator-help/#findComment-612122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.