Jump to content

simple php class code


prezident

Recommended Posts

This is a simple php class code it worked for me before but i don't know what's wrong with it now

This is a little test code to help me understand classes alittle better and i can't get it to work grrrr

 

class person {
    private $name;
    
    function setname($name){
        $this->name=$name;
    }
    function getname($name){
        return $this->$name;
    }
};

$prezident = new person();
$prezident->setname('prezident');

$dayday = new person();
$dayday->setname('dayday');

print $dayday->getname()."<br/>";
print $prezident->getname()."<br/>";

Link to comment
https://forums.phpfreaks.com/topic/223961-simple-php-class-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.