Date: 07/10/01
- Next message: Philip Olson: "Re: [PHP] Line by Line , Word by Word"
- Previous message: Philip Olson: "RE: [PHP] weird behaviour with ("Z" <= "Z")"
- In reply to: Rehuel Lobato de Mesquita: "[PHP] ? : where in the manual?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <email protected>
www.phpbeginner.com
-----Original Message-----
From: Rehuel Lobato de Mesquita [mailto:rehuel <email protected>]
Sent: Wednesday, July 11, 2001 1:16 AM
To: php-general <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: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Philip Olson: "Re: [PHP] Line by Line , Word by Word"
- Previous message: Philip Olson: "RE: [PHP] weird behaviour with ("Z" <= "Z")"
- In reply to: Rehuel Lobato de Mesquita: "[PHP] ? : where in the manual?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

