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 ();
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.