|
-
Jun 28th, 2007, 01:01 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Class constructor being ignored
What am I missing here, the constructor function is being completey ignored... the variables are empty and it doesn't echo the test strings.
Code:
class cart
{
var $item;
var $started;
var $max_qty;
var $symbol;
function cart()
{
$this->started = time();
$this->max_qty = 0;
$this->symbol = "£";
echo "<h1>test</h1>";
echo "<h1>test</h1>";
echo "<h1>test</h1>";
}
-
Jun 28th, 2007, 01:11 PM
#2
Re: Class constructor being ignored
Are you using PHP 4 or 5?
In 5 the constructor function should be named __construct() and var should be replaced with private (or public, as desired).
-
Jun 28th, 2007, 01:15 PM
#3
Thread Starter
Frenzied Member
Re: Class constructor being ignored
Just found it, __construct works yea it must be 5, I've no idea tbh just using an all in one for development. Cheers i'll use privates aswell.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|