Hi, I am having trouble creating a constructor.
The following constructor yields an error message: "Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in /home/flowingb/public_html/admin/login_code.inc on line 13"
Line 13 happens to be function__construct()
class myclass
{
private $balance;
function__construct()
{
$this->balance = 100;
}
}
Thanks, cmartin19
creating a constructor
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: creating a constructor
The word "private" yields the error because you're using PHP 4 instead of PHP 5 
PHP 4 did not have visibility keywords. Use "var" instead.
EDIT | And the constructor won't run with __construct() in PHP4... use the class name instead.
PHP 4 did not have visibility keywords. Use "var" instead.
EDIT | And the constructor won't run with __construct() in PHP4... use the class name instead.