Page 1 of 1

problem with class

Posted: Mon Nov 08, 2004 8:55 am
by pelegk2
i have mdae this class :

Code: Select all

<?php
class purchise_prev{
          var $status;
          function purchise_prev($_status){
             $this->$status=$_status;
          }
          function get_status() { return $this->$status ; }
    }
?>
and

Code: Select all

<?php
$pur_prev = new purchise_prev($row1['status']);

?>
when i try to access the class :
iget
Notice: Undefined variable: status in C:\Program Files\Apache Group\Apache2\htdocs\purchise_new\order_form.php on line 73
where lines 73 is in the get_status()
why is that?
thnaks i nadvance
peleg

Posted: Mon Nov 08, 2004 9:56 am
by phpScott
when using the this key word you don't need to do $this->$status you have to $this->status;

remove the $ infront of status in your class in both methods.

Posted: Mon Nov 08, 2004 9:58 am
by kettle_drum
Too many $'s.

Code: Select all

$this->$status=$_status;
Should be:

Code: Select all

$this->status=$_status;

thnaks

Posted: Mon Nov 08, 2004 11:22 am
by pelegk2
:)