110 likes | 120 Views
This PHP presentation provides a brief explanation of Object Oriented PHP, helping programmers understand the terms and terminologies used in practical OOP. It covers topics such as basics of OOP, object and classes, magic functions, inheritance, visibility, abstract classes, static methods and properties, interfaces, PHP class functions, and autoload.
E N D
Object Oriented Programming with PHP A Presentation byADMEC Multimedia Institute & Web Development Institute (WDI) Delhi Twitter: @admecinstitute www.admecindia.co.in www.web-development-institute.com
PHP Presentation’s Purpose • The purpose of this PHP presentation is to explain Object Oriented PHP in brief. • This PHP presentation can help a PHP programmer in understanding the terms and terminologies used in practical object oriented PHP. • Frameworks of PHP like CodeIgniter, CakePHP, Symphony, Zend etc are MVC based and knowledge of Object Oriented PHP will help in understanding all them. www.admecindia.co.in www.web-development-institute.com
Topics to be Covered • Basics of OOP in PHP • Object & Classes in OOP • Magic Function in PHP OOP • Inheritance (Extending a class) • Visibility (public, private, protected) • Abstract Classes in PHP • Static Methods and properties in PHP • Interfaces in PHP • Explaining PHP Class Functions • Describing Autoload in PHP www.admecindia.co.in www.web-development-institute.com
Concept and Basics of PHP • PHP is a scripting language • Specially a Procedural Programming • Not a true OO Programming • It supports few OO features • Full OOP Support added as of PHP5
What is OOP • It is Object Oriented Programming method of coding. • Allow developer to group multiple similar tasks into classes. • The main aim of OOP is to not repeat the similar code again and again. • With OOP, it is easy to maintain the structure of application and organizing the data • OOP provide simplicity to the complex applications code. www.admecindia.co.in www.web-development-institute.com
Why is OOP Useful in PHP? • Code organization and maintainability • Add clarity • Reduce complexity • Simple rules allow complex interactions • Emphasizes data over procedure • Code modularity or refactoring • Code reusability • Well-suited for databases
Do You Need OOP? • It depends • My PHP OOP rule of thumb • For a simple site, OOP adds unnecessary complexity • For a complex site, OOP adds necessary simplicity
Classes & Objects in PHP Concept of classes & objects can be explained with these two images: • A class, for example, is like a blueprint for a house. It defines the shape of the house on paper, with relationships between the different parts of the house clearly defined and planned out, even though the house doesn't exist. • An object, then, is like the actual house built according to that blueprint. The data stored in the object is like the wood, wires, and concrete that compose the house: without being assembled according to the blueprint, it's just a pile of stuff. However, when it all comes together, it becomes an organized, useful house. www.admecindia.co.in www.web-development-institute.com
Classes & Objects in PHP In PHP class is created using class keyword as shown in the following example classmyOwnClass{ //variables of the classvar $variable1;var $variable2; //Function of class function mergeVariable() { return $this->variable1 . $this->variable2; }} www.admecindia.co.in www.web-development-institute.com
Classes & Objects in PHP There is no use of classes without objects. Object is representative of your class. If created a class then you must need to create object of the class to solve your problem using class. You can create object of your class by using new keyword. $objClass = new myClass(); Now in above code you are creating object of class myClass in variable $objClass. You can create multiple object of your same class. Every object is different from other. $objClass1 = new myClass();$objClass2 = new myClass(); www.admecindia.co.in www.web-development-institute.com
Interesting, right? This is just a sneak preview of the full presentation. We hope you like it! To see the rest of it, just click here to view it in full on PowerShow.com. Then, if you’d like, you can also log in to PowerShow.com to download the entire presentation for free.