PHP Objects: Like other programming languages Java,VB.Net,C# etc php also supports object oriented related concepts.Here we will learn classes and objects conceps in genenral.
Class is a blueprint for object creation and also we can say that object is a real world entity which has state and properties. For Example a bus class may contain speed ,color etc properties by which we can differentiate any other object from bus.
/p>
PHP Objects | Example
Before going deeper into php oops programming let us take a brief tour for oops concepts.
- Class
- Object
- Member Variable
- Member Function
- Inheritance
How to define PHP classes
Here is the example how to define and use simple class in php.
Example
<title></title> <?php class Hello { function myfun($arg1,$arg2) { $arg3 = $arg1 + $arg2; return $arg3; } } $hello=new Hello(); echo $hello-?>myfun( 12, 2); ?> |