>  기사  >  백엔드 개발  >  Parse error: syntax error, unexpected '"class_Rect.php"'解决思路

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

WBOY
WBOY원래의
2016-06-13 12:10:051317검색

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으로 문의하세요.