Say $count = 2 and $max_points = 3 and also vice versa.
$order_points = ($count >= $max_points) ? $max_points : $count;
Thanks.
Can someone tell me what this piece of code is doing?
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: Can someone tell me what this piece of code is doing?
if $count is more than or equal to $max_points then $order_points is changed to $max_points' value, else it is changed to the value of $count.
Google for the ternary operator.
Google for the ternary operator.
-
Phoenixheart
- Forum Contributor
- Posts: 123
- Joined: Tue Nov 16, 2004 7:46 am
- Contact:
Re: Can someone tell me what this piece of code is doing?
Yeah, and it's equivalent to
This can be applied to function executing too, for an example:
Cheers.
Code: Select all
if ($count >= $max_points)
{
$order_points = $max_points;
}
else
{
$order_points = $count;
}
Code: Select all
$count >= $max_points ? do_this() : do_that();
Re: Can someone tell me what this piece of code is doing?
Thanks for the help fellas.