Welcome Guest, Not a member yet? Register   Sign In
An unfamilar if statement
#1

[eluser]ranjudsokomora[/eluser]
Hello CI Coders,
I think this is an easy one, I just need some pointers. I was looking at modifying the router.php file, and stumbled across this code:
Code:
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;

I don't know what the
Code:
? array() : $route

Means, could someone explain or link me documentation on what the question mark, and colon mean?

Thanks
#2

[eluser]danmontgomery[/eluser]
That's the ternary operator.

http://en.wikipedia.org/wiki/?:

Code:
echo ( $val == TRUE ? 'true' : 'false' );

// Same as

if($val == TRUE)
    echo 'true';
else
    echo 'false';




Theme © iAndrew 2016 - Forum software by © MyBB