Mega Code Archive

 
Categories / Php / Class
 

Changing the Value of a Property from Within a Method

<?php  class Item {    var $name = "item";    function setName( $n ) {      $this->name = $n;    }    function getName() {      return $this->name;    }  }  $item = new Item();  $item->setName("widget 5442");  print $item->getName (); ?>