In fact, this is a very easy to solve the problem. In my opinion, déjà vu, hehe, recently learned JavaScript but learned to use VAR to declare variables.
In fact, there is no need to use the Var declaration in PHP, but when a variable as a member of a class variable , the use of Var is not a problem.
Use VAR on the outside error parse Error:syntax error, unexpected T_var in ..., for example, my error message:
Parse error:syntax error, unexpected T_var in D:\Apache2.2\htdocs\shirdrn\page\p2\pageUtil.inc on line 34
I'm testing: Inside a class, an error occurs when you use a class object of your own definition as a member of this class.
The address class corresponds to the Address.inc code:
Copy Code code as follows:
<?php
Class Address {
var $road;
function address () {}
function Setroad ($road) {
$this->road = $road;
}
}
?>
The person class and its test code are person.php as follows:
Copy Code code as follows:
<?php
Require ("Address.inc");
Class Person {
var $name;
var $address;
function person () {
}
function display () {
echo "Name:". $this->name. " <BR> ";
echo "Road:". $this->address->road. " <BR> ";
}
}
var $p = new Person ();
$p->address = new address ();
$p->address->setroad ("Chagnchun Road");
$p->name = "SHIRDRN";
$p->display ();
?>
An exception occurred in the Test loss:
Parse error:syntax error, unexpected T_var in D:\Apache2.2\htdocs\shirdrn\page\p2\pageUtil.inc on line 34
is because the var declaration variable is used in person.php code, which is not possible in PHP, as long as the "$" symbol is used to indicate that the character is followed by a PHP variable.
hehe:-)
Other netizens ' supplemental method:
Problem Resolution: syntax error, unexpected t_string, expecting t_old_function or t_ FUNCTION or T_var or two days before the start of their own PHP trip, do a very common website, the result of our PHP is 5.0 version, the server is 4.0 version, wondering dead slightly. Yesterday was a busy day, and this morning came, in an article found out, the solution. Parse error:syntax error, unexpected t_string, expecting t_old_function or t_function or '} ', if "public", will "pub Lic "removed. There is no error, if "public" is defined variable, change "public" to "Var".