php class and it properties

March 4th, 2016 by Nov Piseth Leave a reply »

In this step I would like to show some identify php class and it properties also identify object of the class as below:

  • class person is identify the class name
  • var $name; var $age; var $gender is proerties of the class person
  • $obj = new Person(); identify variable $obj as object of class Person
  • so $obj can access all properties and method in class person

<?php
class Person {
var $name;
var $age;
var $gender;
}
$obj = new Person();

$obj->name ="Dara";
$obj->age = 15;
$obj->gender = "Male";

echo "Person Name: $obj->name <br />";
echo "Person Age: $obj->age <br />";
echo "Person Gender: $obj->gender <br />";
?>

Advertisement

Comments are closed.

WP Facebook Auto Publish Powered By : XYZScripts.com