php error unexpected,PHP异常Parse error: syntax error, unexpected错误解决方法
在PHP中根本不需要使用var声明的,但是当一个变量作为一个类的成员变量的时候,使用var还是没有问题的
其实,这是一个非常容易解决掉的问题。在我看来,似曾相识,呵呵,最近学JavaScript可是学会了使用var声明变量。
其实,在PHP中根本不需要使用var声明的,但是当一个变量作为一个类的成员变量的时候,使用var还是没有问题的。
在外部使用var就报错Parse error: syntax error, unexpected T_VAR in...,例如我的出错信息:
Parse error: syntax error, unexpected T_VAR in D:\Apache2.2\htdocs\shirdrn\page\p2\pageUtil.inc on line 34
我在测试:在一个类的内部,使用一个自己定义的类对象作为这个类的成员时,出错了。
Address类对应的address.inc代码:
代码如下:<?php
class Address {
var $road;
function Address(){}
function setRoad($road){
$this->road = $road;
}
}
?>
Person类及其测试代码为person.php如下:
代码如下:<?php
require("address.inc");
class Person {
var $name;
var $address;
function Person(){
}
function display(){
echo "Name : ".$this->name."
";
echo "Road : ".$this->address->road."
";
}
}
var $p = new Person();
$p->address = new Address();
$p->address->setRoad("Chagnchun Road");
$p->name = "Shirdrn";
$p->display();
?>
测试输出现异常:
Parse error: syntax error, unexpected T_VAR in D:\Apache2.2\htdocs\shirdrn\page\p2\pageUtil.inc on line 34
就是因为在person.php代码中使用var声明变量,PHP中是不能这样的,只要使用“$”符号起始就表示这个字符后面的是一个PHP变量。
本文原创发布php中文网,转载请注明出处,感谢您的尊重!
php error unexpected,PHP异常Parse error: syntax error, unexpected错误解决方法相关推荐
- Error generating final archive: Debug Certificate expired on 的错误解决方法
Android开发中 Error generating final archive: Debug Certificate expired on 的错误解决方法 问题概述: 在导入一个app后提示如下错 ...
- npm 出现Unexpected end of JSON input while parsing near错误解决方法
npm install 的时候出现错误: npm ERR! Unexpected end of JSON input while parsing near '...","webpa ...
- Import error: no module named cv2 错误解决方法
Import error: no module named cv2 错误解决方法 参考文章: (1)Import error: no module named cv2 错误解决方法 (2)https: ...
- HTTP 错误 500.19- Internal Server Error 错误解决方法
HTTP 错误 500.19- Internal Server Error 错误解决方法 参考文章: (1)HTTP 错误 500.19- Internal Server Error 错误解决方法 ( ...
- Error parsing HTTP request header Larger错误解决方法
Error parsing HTTP request header Larger错误解决方法 参考文章: (1)Error parsing HTTP request header Larger错误解决 ...
- Error, some other host already uses address 192.168.0.202错误解决方法
Error, some other host already uses address 192.168.0.202错误解决方法 参考文章: (1)Error, some other host alre ...
- Xcode真机调试中“There was an internal API error“错误解决方法
Xcode真机调试中"There was an internal API error"错误解决方法 参考文章: (1)Xcode真机调试中"There was an in ...
- DB2 SQL Error: SQLCODE=-668, SQLSTATE=57016错误解决方法
DB2 SQL Error: SQLCODE=-668, SQLSTATE=57016错误解决方法 参考文章: (1)DB2 SQL Error: SQLCODE=-668, SQLSTATE=570 ...
- connection error mysql_MySQL ConnectionError 安装错误 解决方法
MySQL ConnectionError The security settings could not be applied to the database because the connect ...
- win7 、2008 提示Error 1606 Could Not Access Network Location %SystemDrive%/inetpub/wwwroot/ 的错误解决方法
win7 .2008 提示Error 1606 Could Not Access Network Location %SystemDrive%/inetpub/wwwroot/ 的错误解决方法 参考文 ...
最新文章
- Keras TensorFlow教程:使用自己的数据集进行训练
- Window 7上架设SSRS 2005时遇到的几点小麻烦
- 不会英语计算机开车和,驾校学车的那些事儿——技术篇
- 雪妖现世:给SAP Fiori Launchpad增添雪花纷飞的效果
- 第三部分 Calendar函数接口
- 高管暗示Redmi Note 10系列新品:今日有大事公布?
- sublime text3 保存文件时候名字后缀.dump问题解决
- (补充)【打印1到最大的n位数】剑指offer——面试题12:打印1到最大的n位数
- sql注入pythonpoco_骑士CMS后台SQL注入 | CN-SEC 中文网
- go语言练习:条件语句和循环语句
- 对话Man Group:对冲基金的达尔文式竞争
- visio 2003密钥
- python get请求下载excel,前端开发,使用get和post方式下载excel表格
- Unity 接入百度AI - Logo商标识别
- 烽火fr2600怎么web登录_烽火配置教程
- Retrofit,RecyclerViewMVP模式
- 营造美好婚姻的30个提醒
- 轻听-最好的解压助眠医疗轻音乐集
- GPS从入门到放弃(一)、GPS 定位原理
- access 数据计算,常用函数