Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> What Does This Do?, $ban = ($data->login) ? $lban : $iban;
peroim
post 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
Go to the top of the page
 
+Quote Post
jlhaslip
post 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 Icon

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
Spam Patrol



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
Go to the top of the page
 
+Quote Post
Amezis
post 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;
}
Go to the top of the page
 
+Quote Post
FLaKes
post 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.
Go to the top of the page
 
+Quote Post
peroim
post 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 smile.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Finding Data In Meta Tags(0)
  2. Customizing Login Script(8)
  3. Login / Authetication System Using Database(4)
  4. "grand" Login System?(7)
  5. Same 1 Registeration Data For Different Purposes(4)
  6. Loading Mysql Data Into A Table(10)
  7. Automatic Login Using Curl(1)
  8. Sessions And Login(5)
  9. Login Script(11)
  10. .htaccess-style Login System And Php(13)
  11. How Good Is This Data Cleaning Function?(2)
  12. Help Improving My Login Script Code(4)
  13. Putting Data Of 2 Pages In Mysql At Once(1)
  14. Problems With Data Formatting(2)
  15. New Arisen Site Problem(2)
  1. <?php ?> Sloppy Login Script(12)
  2. Login System Help...(3)
  3. Phpmyadmin Login Problem!(1)
  4. Is This A Good Script?(9)
  5. Using Multiple Selection Array In Table To Order Data(1)
  6. Windows Login Credentials(0)
  7. Creating A Login Box That Links To My Phpbb Forum(4)
  8. Php Login Script(1)
  9. Login System(6)
  10. Html Site With Login(2)
  11. Php Email Validation(1)
  12. Php + Mysql Question!(4)
  13. One Login Account At One Time(3)


 



- Lo-Fi Version Time is now: 7th October 2008 - 12:25 AM