PHP objects

Alexej Kubarev

New member
you are using the wrong syntax:
$this->$var
It is the wrong syntax: there shouldn't be a $ sign before var:
$this->var
is the correct one

Therefore your class hould look like this:
Code:
<?php
class timeline {
    var $event;
    var $begintime;
    var $duration;
    var $recurring;
    var $detail;
    
    function assign_vals() {
       $this->event = 'test event';
       $this->begintime = '1/1/01';
       $this->endtime = '1/2/01';
       $this->recurring = 'no';
       $this->detail = 'Details, etc';
    }
    
    function print_timeline() {
       
       echo "<br>1<br>";
       echo $this->event;
       echo "<br>2<br>";
       echo $this->begintime;
       echo "<br>3<br>";
       echo $this->endtime;
       echo "<br>4<br>";
       echo $this->detail;
       echo "<br>5<br>";
       echo $this->recurring;
    }
 }
?>
 
Back
Top