This document serves as a comprehensive study guide for Object Oriented Programming (OOP) in PHP, covering essential topics such as PHP basics, functions, arrays, security, and databases. It details key OOP concepts like classes, interfaces, exceptions, and the Reflection API, along with their functionalities and usage. Additionally, it discusses advanced features like type hinting and late static binding, providing a thorough understanding of OOP principles in PHP.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views3 pages
Object Oriented Programming
This document serves as a comprehensive study guide for Object Oriented Programming (OOP) in PHP, covering essential topics such as PHP basics, functions, arrays, security, and databases. It details key OOP concepts like classes, interfaces, exceptions, and the Reflection API, along with their functionalities and usage. Additionally, it discusses advanced features like type hinting and late static binding, providing a thorough understanding of OOP principles in PHP.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3
Object Oriented Programming
PHP Study Guide
PHP Basics Functions Strings & Patterns Arrays I/O Security Databases Object Oriented Programming Data Formats & Types Web Features Design and Theory Object Oriented Programming Facts PPP & F Constants, Static Interfaces & Abstract Classes Instanceof Autoloading Special Functions Exceptions SPL Reflection API Type Hinting Late Static Binding Facts Prior to PHP5 OOP was a hack on top of the array implementation Slower than procedural code, but allows complex tasks to be understood more readily Objects are now dealt with by reference rather than by value, objects must be explicitly cloned to be copied PPP & F Public – Method or property can be accessed externally Private – Method or property is private to that class and can not be accessed externally Protected – Method or property is private and can also be accessed by extending classes Final – Method can not be overridden by extending classes Constants, Static are accessible as part of a class itself calling static properties using object notation will result in a notice by default the static method or property is considered public Class constants are public, and accessible from all scopes constants can only contain scalar values much cleaner code significantly faster than those declared with the define() construct Interfaces & Abstract Classes New feature added to PHP 5 used to create a series of constraints on the base design of a group of classes You must declare a class as abstract so long as it has (or inherits without providing a body) at least one abstract method. a class can only extend one parent class, but it can implement multiple interfaces. Instanceof Allows you to inspect all of the ancestor classes of your object, as well as any interfaces Autoloading 1 2 3 <?php function __autoload($class_name) { 4 5 6 require_once "/www/phpClasses/{$class_name}.inc.php"; } $a = new friend; http://php-guide.evercodelab.com/pages/oop.html 1/210/06/2017 Object Oriented Programming Special Functions http://php.net/manual/en/language.oop5.magic.php __construct() __destruct() - Destruction occurs when all references to an object are gone, and this may not necessarily take place when you expect it or even when you want it to. __toString() __sleep() __wakeup() __call() __get() __set() Exceptions Unified method of error handling Makes proper error handling possible Can be accomplished with try catch blocks or by setting a unified error handler once Try catch blocks take precedence if the error raising code is within them are objects, created (or “thrown”) when an error occurs All unhandled exceptions are fatal. catch() portion of the statement requires us to hint the type of Exception callback set_exception_handler ( callback $exception_handler ) bool restore_exception_handler ( void ) SPL allow to stack autoloaders on top of each other void spl_autoload ( string $class_name [, string $file_extensions = spl_autoload_extensions() ] ) string spl_autoload_extensions ([ string $file_extensions ] ) bool spl_autoload_register ([ callback $autoload_function [, bool $throw = true [, bool $prepend = false ]]] ) - first call to this function replaces the __autoload() call in the engine with its own implementation Reflection API http://php.net/reflection provides a manner to obtain detailed information about code $func = new ReflectionFunction($func); ReflectionClass ReflectionMethod array get_defined_functions ( void ) array get_object_vars ( object $object ) Type Hinting http://www.php.net/manual/en/language.oop5.typehinting.php Late Static Binding http://php.net/manual/en/language.oop5.late-static-bindings.php 1 Comment Recommend 1 PHP study guide Login Sort by Best ⤤ Share Join the discussion… MAS BEJO • 3 years ago WHATS IS THIS?????????????????????? 2 △ ▽ • Reply • Share › ✉ Subscribe d Add Disqus to your siteAdd DisqusAdd 🔒 Privacy http://php-guide.evercodelab.com/pages/oop.html 2/2