PHP OOPS | Object Oriented Programming

//$obj2 = new MyClass2();

OOP Features Supported by PHP5:constructor-destructor,interfaces, abstract classes,object cloning,  name spacing
OOP Features Not Supported by PHP:Method overloading,Operator overloading,Multiple inheritance;


const,


features:data hiding ,abstraction,reusability, polymorphism


//0. Property Scopes:public, private, protected, final, and static(self::$visitors++;)
    Method Scopes :public, private, protected, abstract, final, and static(class_name::method_name();).

//1.class, data member(properties),constant(classname::$pie;)
,member function
//2. creating object , accessing(this) data member and member function
Instanceof keyword(if ($manager instanceof Employee) echo "Yes";)
//3. access specifier
//4. how can see private data member
//5. constant variable and acessing constant variable
//6.constructor  (Invoking Parent Constructors   parent::),
//7. multiple instances of class
//8. inheritance(extends) and overriding
//9. interface(variable not possible in interface)
// example of multiple inheritance
//10. connecting databases in oops way

class demo
{
// by default data member is private


public $bal=5000;    // data memeber and access specifier //public,private and //protected


function fun($name)//member function
{


echo"hello $name!!!!!";
return "Your balance = $this->bal"; //accesing class variable and returning property value
}


}


$obj=new demo();



function __autoload($class_name) {
   require $class_name . '.php';
}

$obj  = new Friend();
Friend.php
<?php
class Friend{

function Friend(){
echo "Hello from Friend";
}

}

?>




Reactions: