PHP下include包含文件问题

WBOY
Release: 2016-06-23 14:38:45
Original
898 people have browsed it

我的代码:

<?php		require("header.inc.php");		function __autoload($className)		{			include $className."__class.php";		}		$DbModle=new ProductModle();		$allProduct=$DbModle->selectAllProduct();		if($allProduct)		{			echo '<table align="center" width="90%" border="1">';			echo '<caption>商品列表</caption>';			echo '<th>产品ID</th><th>名称</th><th>价格</th><th>编辑</th>';			foreach($allProduct as $product)			{				echo '<tr>';				echo '<td>'.$product->getId().'</td>';				echo '<td>'.$product->getName().'</td>';				echo '<td>'.$product->getPrice().'</td>';				echo '<td>';				echo '<a href="editview.php?action=modify&productID='.$product->getId().'">修改</a>';				echo '<a href="control.php?action=delete&productID='.$product->getId().'">删除</a>';				echo '</td></tr>';			}			echo '</table>';		}		else		{			echo '<p align="center">没有任何商品</p>';		}		echo '<center><a href="editview.php?action=add">添加商品</a></center>';		require("footer.inc.php");	?>
Copy after login

运行截图:


回复讨论(解决方案)

你应该在 __autoload 中检查文件 $className."__class.php" 是否真实存在

文件不存在或者路径错误...

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template