Jump to content
xisto Community
Sign in to follow this  
peroim

What Does This Do? ban = (data-login) ? lban : iban;

Recommended Posts

I'm correcting a 'few' php-files for a friend, but I got this line of 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

Share this post


Link to post
Share on other sites

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://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.