include ( $_GET['p'] == 'home') ? 'pages/home.php' : NULL;
gives the error:
Notice: Undefined index: p in /var/www/index.php on line 38
Warning: require(): Filename cannot be empty in /var/www/index.php on line 38
Fatal error: require(): Failed opening required '' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/index.php on line 38
I understand the undefined index, but why am I getting the other errors? This line:
include ( !isset($_GET['p'])) ? 'pages/home.php': NULL;
works fine. Note that the first code will work fine in an if statement (apart from the undefined index, which I understand)