problem with class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

problem with class

Post 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
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Too many $'s.

Code: Select all

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

Code: Select all

$this->status=$_status;
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

thnaks

Post by pelegk2 »

:)
Post Reply