Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to access a private property in PHP

php form submission

This is a basic PHP program based on object oriented programming which explain how to use the private access modifier in PHP with an example and output.

The Private modifier is called with the private keyword before defined class name. After this tutorial, your basic concept of Object oriented programming will be clear.

How to access a private property in PHP

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

Program Output

The car model is Mercedes benz.

Liked this program? Do Like & share with your friends.

The post How to access a Private Property in PHP appeared first on FreeWebMentor.



This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here

Share the post

How to access a private property in PHP

×

Subscribe to Programming Blog Focused On Web Technologies

Get updates delivered right to your inbox!

Thank you for your subscription

×