|
-
Oct 7th, 2005, 08:10 AM
#1
Thread Starter
Hyperactive Member
Noob QUESTION HERE...
okay...Ive used this effectively once before.... but i havent used it in a while and cant remember where in the book i saw it... and where in php.net i seen an example used with it...
i feel kinda silly... but im here... asking away anyways...lol...
the thing im looking for is...sumtin like
PHP Code:
($row['blah']==""?"0":$row['blah'])
Without balance, there could only be chaos.
Without chaos, there could be no balance.
I live with karma. Eat with destiny. Dream of life without shackles....
Yet. If life had no consequences, life could not exist, nor could it flourish.
If at first you dont succeed.You're screwed.
C++/Java NOOB.
I aint a professional at PHP, but if i can help i will.
-
Oct 7th, 2005, 11:06 AM
#2
Lively Member
Re: Noob QUESTION HERE...
That's an if statement that uses the ternary operator:
PHP Code:
// one liner
$foobar = ($row['blah']== "") ? "0" : $row['blah'];
// would look like this written out
if($row['blah'] == "")
{
$foobar = "0";
}
else
{
$foobar = $row['blah'];
}
-
Oct 8th, 2005, 06:12 PM
#3
Thread Starter
Hyperactive Member
Re: Noob QUESTION HERE...
hmm... okay.... thanks... lol... that helped.
It seems bery useful.Confusing... but useful nontheless.
Hmm... What would i look for on PHP.NET for more examples of this...?
i tried ternary , ternary operations, ternary operator, ternary operators
Last edited by PlaGuE; Oct 8th, 2005 at 06:17 PM.
Without balance, there could only be chaos.
Without chaos, there could be no balance.
I live with karma. Eat with destiny. Dream of life without shackles....
Yet. If life had no consequences, life could not exist, nor could it flourish.
If at first you dont succeed.You're screwed.
C++/Java NOOB.
I aint a professional at PHP, but if i can help i will.
-
Oct 8th, 2005, 06:48 PM
#4
Lively Member
Re: Noob QUESTION HERE...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|