CodeIgniter Forums
An unfamilar if statement - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: An unfamilar if statement (/showthread.php?tid=30840)



An unfamilar if statement - El Forum - 05-27-2010

[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


An unfamilar if statement - El Forum - 05-27-2010

[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';