[ create a new paste ] login | about

Link: http://codepad.org/VlUWd2eq    [ raw code | output | fork ]

PHP, pasted on Feb 27:
<?php

class Car {
 
  //the private access modifier denies access to the method from outside the class’s scope
  
 
  //the public access modifier allows the access to the method from outside the class
  public function setModel($model)
  {
    $this -> model = $model;
  }
  
  public function getModel()
  {
    return "The car model is  " . $this -> model;
  }
}
 
$mercedes = new Car();
//Sets the car’s model
$mercedes -> setModel("Mercedes benz");
//Gets the car’s model
echo $mercedes -> getModel();

?>


Output:
1
The car model is  Mercedes benz


Create a new paste based on this one


Comments: