RE: [PHP] ? : where in the manual?

From: Date: Tue, 10 Jul 2001 16:52:16 +0000
Subject: RE: [PHP] ? : where in the manual?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-57206@lists.php.net to get a copy of this message
same from : header("Location: ".(empty($SESSION["wantsurl"]) ? $CFG->wwwroot : $SESSION["wantsurl"])); Exit; or, if not readable enough then: if(empty($SESSION["wantsurl"])) { $goto = $CFG->wwwroot; } else { $goto = $SESSION["wantsurl"]; } header("Location: $goto"); Exit; // or die; (condition) ? 'result if true' : 'if false'; is exactly same thing as: if(condition) { 'result if true'; } else { 'if false'; } the only difference: it can be only one line (one semilon ';') on any of the two results and can be only ONE evaluation (no 'elseif') and must have an 'else'; I'll tell you also a few reasons to use this syntax: 1. less lines for PHP to compile. 2. saves you the headache when there are lot's of conditions to do inside the strings or function returns; 3. less useless variables to declare. Good question though, where is this documented? I knew it from other languages... but never came accross it on PHP docs except the code samples.. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: Rehuel Lobato de Mesquita [mailto:rehuel@cq-link.sr] Sent: Wednesday, July 11, 2001 1:16 AM To: php-general@lists.php.net Subject: [PHP] ? : where in the manual? Heya guys, I am trying to find information in the manual to explain these lines: $goto = empty($SESSION["wantsurl"]) ? $CFG->wwwroot : $SESSION["wantsurl"]; header("Location: $goto"); die; Can anyone tell me where to look??? Thanx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#57206) next »