Parse error: syntax error, unexpected '"class_Rect.php"'
<html><br /> <head><br /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br /> <title>图形的周长和面积计算器</title><br /> </head><br /><br /> <body><br /> <br /> <?php<br /> //自动加载<br /> requireonce"class_Rect.php";<br /> requireonce"class_Triangle.php";<br /> requireonce"class_Circle.php";<br /><br /> function __autoload($className){<br /> include("class_".ucfirst($className).".php");<br /> }<br /> ?><br /> <center><br /> <h2>图形的周长和面积计算器</h2><br /> <hr><br /> <a href="test.php?action=1">矩形</a>||<br /> <a href="test.php?action=2">三角形</a>||<br /> <a href="test.php?action=3">圆形</a><hr><br /> </center><br /><br /> <?php<br /> switch($_REQUEST["action"]) {<br /> case '1':<br /> $form=new Form("矩形",$_REQUEST,"test.php");<br /> echo $form;<br /> break;<br /><br /> case '2':<br /> $form=new Form("三角形",$_REQUEST,"test.php","post","_blank");<br /> echo $form;<br /> break;<br /><br /> case '3':<br /> $form=new Form("圆形",$_REQUEST,"test.php");<br /> echo $form;<br /> break;<br /><br /> default:<br /> echo "请选择一个形状<br>";<br /> <br /> }<br /><br /> if (isset($_REQUEST["act"])) {<br /> switch ($_REQUEST["act"]) {<br /> case '1':<br /> $shape=new Rect($_REQUEST);<br /> break;<br /><br /> case '2':<br /> $shape=new Triangle($_REQUEST);<br /> break;<br /><br /> case '3':<br /> $shape=new Circle($_REQUEST);<br /> break;<br /> <br /> }<br /><br /> echo "面积为:".$shape->area()."<br>";<br /> echo "周长为:".$shape->perimeter()."<br>";<br /> }<br /> ?><br /><br /> </body><br /></html> ------解决思路----------------------
引用:
<html><br /> <head><br /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br /> <title>图形的周长和面积计算器</title><br /> </head><br /><br /> <body><br /> <br /> <?php<br /> //自动加载<br /> require_once "class_Rect.php";<br /> require_once "class_Triangle.php";<br /> require_once "class_Circle.php";<br /><br /> function __autoload($className){<br /> include("class_".ucfirst($className).".php");<br /> }<br /> ?><br /> <center><br /> <h2>图形的周长和面积计算器</h2><br /> <hr><br /> <a href="test.php?action=1">矩形</a><br><font color='#FF8000'>------解决思路----------------------</font><br><br /> <a href="test.php?action=2">三角形</a><br><font color='#FF8000'>------解决思路----------------------</font><br><br /> <a href="test.php?action=3">圆形</a><hr><br /> </center><br /><br /> <?php<br /> switch($_REQUEST["action"]) {<br /> case '1':<br /> $form=new Form("矩形",$_REQUEST,"test.php");<br /> echo $form;<br /> break;<br /><br /> case '2':<br /> $form=new Form("三角形",$_REQUEST,"test.php","post","_blank");<br /> echo $form;<br /> break;<br /><br /> case '3':<br /> $form=new Form("圆形",$_REQUEST,"test.php");<br /> echo $form;<br /> break;<br /><br /> default:<br /> echo "请选择一个形状<br>";<br /> <br /> }<br /> <br /><br /> if (isset($_REQUEST["act"])) {<br /> switch ($_REQUEST["act"]) {<br /> case '1':<br /> $shape=new Rect($_REQUEST);<br /> break;<br /><br /> case '2':<br /> $shape=new Triangle($_REQUEST);<br /> break;<br /><br /> case '3':<br /> $shape=new Circle($_REQUEST);<br /> break;<br /> <br /> }<br /><br /> echo "面积为:".$shape->area()."<br>";<br /> echo "周长为:".$shape->perimeter()."<br>";<br /> }<br /> ?><br /><br /> </body><br /></html>
这里的报错是显示$_REQUEST["action"]不存在,没有这个索引
你需要判断是否为空
<br />$action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : '';<br />switch($action)<br />{<br />//。。。。。。。。<br />}<br />
Statement: 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