Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unexpected T_STRING parse error, but where's the error?! 1

Status
Not open for further replies.

LaundroMat

Programmer
Joined
Dec 2, 2003
Messages
67
Location
BE
This code (got it from Core PHP programming, 3rd edition)

Code:
<?php
	//define class for tracking users
	class User
	{
		//properties
		public $name;
		private $password, $lastLogin;

		//methods
		public function __construct($name, $password)
		{
			$this->name = $name;
			$this->password = $password;
			$this->lastLogin = time();
			$this->accesses++;
		}

		// get the date of the last login
		function getLastLogin()
		{
			return(date(&quot;M d Y&quot;, $this->lastLogin));
		}
	}

	//create an instance
	$user = new User(&quot;Leon&quot;, &quot;sdf123&quot;);

	//get the last login date
	print($user->getLastLogin() .&quot;<br>\n&quot;);

	//print the user's name
	print(&quot;$user->name<br>\n&quot;);
?>
gives this error:
Code:
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in C:\phpdev\[URL unfurl="true"]www\COREPH~1\corephp\6-1.php[/URL] on line 6

I'm using PHP 4.2.3. This does support all that is objects, right?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top