Changing the Value of a Property from Within a Method : Class Property : Class PHP Source Code


PHP Source Code » Class » Class Property »

 

Changing the Value of a Property from Within a Method




<html>
<head>
<title>Changing the Value of a Property from Within a Method</title>
</head>
<body>
<?php
class first_class{
    var $name="Joe";
    function setName$n ){
        $this->name = $n;
    }
    function sayHello(){
        print "my name is $this->name<BR>";
    }
}

$obj1 = new first_class();
$obj1->setName("new name");
$obj1->sayHello();

?>
</body>
</html>

           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Class
» Class Property