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)
[EMAIL PROTECTED]
www.phpbeginner.com
-----Original Message-----
From: Rehuel Lobato de Mesquita [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 11, 2001 1:16 AM
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]