|
|
|
|
![]() ![]() |
Mar 12 2007, 08:10 PM
Post
#1
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 33 Joined: 9-July 06 From: Belgium Member No.: 26,367 |
I'm correcting a 'few' php-files for a friend, but I got this line of code:
CODE $ban = ($data->login) ? $lban : $iban; and I don't know what it does xD Could someone please explain me what this line does? Thanks |
|
|
|
Mar 12 2007, 09:26 PM
Post
#2
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 4,076 Joined: 24-July 05 From: Linix, DOS and Windows…the good, the bad and the ugly Member No.: 9,787 ![]() |
That is a terniary (sp) statement. Like an IF statement, but very concise.
If the condition [$ban = ($data->login)] is evaluated to true, then perform the assignment following the '?'. [$lban] If the condition [$ban = ($data->login)] is evaluated to false, then perform the assignment following the ':'. [$iban] see also here at the php.net site: http://ca.php.net/manual/en/control-struct...yntax.php#35574 |
|
|
|
Mar 22 2007, 07:30 PM
Post
#3
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 535 Joined: 14-February 05 From: Oslo, Norway Member No.: 3,759 |
It's the same code as this:
CODE if ($data->login) {
$ban = $lban; } else { $ban = $iban; } |
|
|
|
Mar 23 2007, 01:42 AM
Post
#4
|
|
|
Trap Grand Marshal Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 1,137 Joined: 19-May 05 From: Mexico Member No.: 7,234 |
Excellent... thanks jhaslip. I had bumped into terniary operators on a php tutorial before but the tutorial explained them and I didnt quite get them. I didnt understand. And a search in google didnt help me much either.
|
|
|
|
Mar 31 2007, 11:43 AM
Post
#5
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 33 Joined: 9-July 06 From: Belgium Member No.: 26,367 |
i can understand it too now, thanks
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 7th October 2008 - 12:25 AM |