Thread: PHP class
View Single Post
Old Jul 12th, 2006, 6:22 PM   #5
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 437
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Your class should be as follows dark_omen:
<?php
class myClass{
    var $h;

    //constructor
    function __construct(){
        $this->$h = "Hello";
    }
    
    function write(){
        return $this->$h;
    }
}
?>
So basically for any instance field of the class or when you want to return a value which uses an instance field in its computations, you have to specify $this-> in your code. Also, your constructor for the class is always named __construct. And that should make your class work as you want it to.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote