首页  >  文章  >  后端开发  >  Parse error: syntax error, unexpected '"class_Rect.php"'解决思路

Parse error: syntax error, unexpected '"class_Rect.php"'解决思路

WBOY
WBOY原创
2016-06-13 12:10:051313浏览

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 />
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn