chp1 semII
chp1 semII
• // member function
• public function displayVar()
• {
• echo $this->var;
• }
• }
• $hello= new bca; //hello is object of class bca
• $hello-> displayVar();
• ?>
• To create an object of a given class use the new keyword
The child class will inherit all the public and protected properties
and methods from the parent class.
• $yes_no = class_exists(classname);
• $methods = get_class_methods(classname);
• $properties = get_class_vars(classname);
• $superclass = get_parent_class(classname);
• Cal1.html
• Intro1.php
Object functions
• To get the class to which an object belongs, first make sure it is an object
using the is_object( ) function, then get the class with the get_class( )
function:
• $yes_no = is_object(var);
• $classname = get_class(object);
• Before calling a method on an object, you can ensure that it exists using
the method_exists( ) function:
• $yes_no = method_exists(object, method);
• Just as get_class_vars( ) returns an array of properties for a
class, get_object_vars( ) returns an array of properties set in an
object:
• $array = get_object_vars(object);