LaundroMat
Programmer
This code (got it from Core PHP programming, 3rd edition)
gives this error:
I'm using PHP 4.2.3. This does support all that is objects, right?
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("M d Y", $this->lastLogin));
}
}
//create an instance
$user = new User("Leon", "sdf123");
//get the last login date
print($user->getLastLogin() ."<br>\n");
//print the user's name
print("$user->name<br>\n");
?>
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?