Re: [PHP] snippet
Everything has been explained, I will just mention this is more efficient, as submit() function runs only once: $sFont =($tmp=submit(font)) ? SITE_ROOT . PROG_PATH . $tmp : ; Harry Wiens wrote: can someone explain this for me: ... $sFont =submit(font) ? SITE_ROOT . PROG_PATH . submit(font) : ; ... mfg. hwiens -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] snippet
hi It is a Ternary Operator, Often you can avoid large if/else statements in your code by using the ternary operator. For example: echo You have $i . ($i==1 ? message : messages). in your box.\n; Note: ? : operator has this syntax expr ? expr : expr; imran - Original Message - From: Harry Wiens [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 3:26 PM Subject: [PHP] snippet can someone explain this for me: ... $sFont =submit(font) ? SITE_ROOT . PROG_PATH . submit(font) : ; ... mfg. hwiens -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] snippet
** CORRECTION BELOW ** Hello, This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at 11:14, lines prefixed by '' were originally written by you. $sFont =submit(font) ? SITE_ROOT . PROG_PATH . submit(font) : ; it is the same as: if(submit(font)){ $sFont = SITE_ROOT . PROG_PATH; } else { $sFont = ; } (see http://uk.php.net/language.operators.comparison) submit() is a user defined function, if it evaluates to **TRUE** then $sFont will contain the value of those two constants put togetherm otherwise it will be set to an empty string. HTH David. -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Free PHP error handling script: www.phpmachine.com/error-handler/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] snippet
can someone explain this for me: ... $sFont =submit(font) ? SITE_ROOT . PROG_PATH . submit(font) : ; ... mfg. hwiens -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] snippet
Hello, This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at 11:14, lines prefixed by '' were originally written by you. $sFont =submit(font) ? SITE_ROOT . PROG_PATH . submit(font) : ; it is the same as: if(submit(font)){ $sFont = SITE_ROOT . PROG_PATH; } else { $sFont = ; } (see http://uk.php.net/language.operators.comparison) submit() is a user defined function, if it evaluates to false then $sFont will contain the value of those two constants put togetherm otherwise it will be set to an empty string. HTH David. -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Free PHP error handling script: www.phpmachine.com/error-handler/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] snippet
Hi Harry, can someone explain this for me: ... $sFont =submit(font) ? SITE_ROOT . PROG_PATH . submit(font) : ; ... It's called the ternary operator, and it's a shorthand for if...else... The line you're asking about is equivalent to: if (submit(font)) { $sFont = SITE_ROOT . PROG_PATH . submit(font); } else { $sFont = ; } The format is: (condition to check) ? (result if true) : (result if false); Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php