Forum Moderators: coopster

Message Too Old, No Replies

PHP4, access class data member in member function

throws a notice of undefined variable.

         

phparion

7:58 am on Mar 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi

I have to work on PHP4 OOP for a project and facing a NOTICE problem. Since I am a 'detailed' coder therefore I want my script to be free of any warning, notice or such things which are normally hidden or in other words many developers hide.

I declared a data member as

class clsName {
var $visioVoto;

function checkMe() {
echo $this->$visioVoto;
}

}

I get a NOTICE OF VARIABLE UNDEFINED. Why is this happening? because I already declared it in the class and accessing with $this.

thank you

dreamcatcher

8:47 am on Mar 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



echo $this->$visioVoto;

Should be:

echo $this->visioVoto;

dc

phparion

10:26 am on Mar 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



after reading your reply I shouted so loud that everybody ran to my office to see if I am crushed under something :D .. when the hell I will be able to code without typos... thank you very much dreamcatcher! you will come in my dreams tonight :)

dreamcatcher

7:56 pm on Mar 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Happens to all of us I`m afraid. Always good to use a second pair of eyes.

dc