Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Define getter and setter in php class

Sun Oct 26, 2008 11:54 pm

Code:
<?php

   
class Staff {
      
private $name;

      
// Getter
      
public function getName() {
         return
$this->name;
      }

      
// Setter
      
public function setName($name) {
         
$this->name = $name;
      }
   }
?>




Post a reply
  Related Posts  to : Define getter and setter in php class
 Define class helper class to check the method existance     -  
 Define class inside another class C++     -  
 define a Class with a Method     -  
 how to Define abstract class in php     -  
 define final class     -  
 Define your own exception class     -  
 Define Enum inside a class     -  
 Define boolean Class properties     -  
 java abstract class,concrete class and interface     -  
 Define new namespaces in C++     -  

Topic Tags

PHP OOP