我有一个PHP警告一个小问题:显示不同势内容,如果有一个警告信息
我基本上要通过点击链接,这样来改变我的网页的内容:
<?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");?>
这个作品真的很好,但是当我使用的页面不存在,例如 localhost/dir/index.php?page=notapage
我收到以下错误:
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
是否有可能取代此警告是由自定义消息? (如“404找不到”)
在此先感谢和快乐的复活节!
非常感谢!这正是我正在寻找的:) – muffin