I have a little problem with a PHP warning:
I basically want to change the content of my page by clicking on links, like this:
<?php $page = ((!empty($_GET['page'])) ? $_GET['page'] : 'home'); ?>
<h1>Pages:</h1>
<ul>
<li><a href="index.php?page=news">News</a></li>
<li><a href="index.php?page=faq">F.A.Q.</a></li>
<li><a href="index.php?page=contact">Contact</a></li>
</ul>
<?php include("$page.html");?>
This works really fine, but when I use a page that doesn't exist, for example
localhost/dir/index.php?page=notapage
i get following error:
Warning: include(notapage.html): failed to open stream: No such file or directory in
C:\xampp\htdocs\dir\index.php on line 8
Warning: include(): Failed opening 'notapage.html' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\dir\index.php on line 8
Is it possible to replace this warning by a custom message? (like a "404 not found")
Thanks in advance and happy easter!