Object in OOP PHP
This tutorial series is for both beginners and middle level programmer who want to learn advance concept of OOP in PHP from basic . In this series we will explore all aspect of OOP in PHP from beginning. Object oriented programming is a technique to design your application. Application could be any type like it could be web based application, windows based application. OOP is a design concept. In object oriented programming, everything will be around the objects and class. By using OOP in PHP you can create modular web application. By using OOP in PHP we can perform any activity in the object model structure. In this article we are going explore exactly what OOP is in relation to PHP, and look at a few things you should remember about it as well. We’ll end of with a simple example of how to use it.
What is Object?
PHP is an object-oriented programming language, which means that you can create objects, which can contain variables and functions. When talking about objects, you refer to variables belonging to these objects as properties (or attributes or fields), and functions are called methods. Object in programming is similar to real word object. Every programming object has some properties and behaviours. Your car has property (colour, brand name) and behaviour(it can go forward and backward). If you are able to find properties and behaviours of real object. Then it will be very easy for you to work with Object Oriented Programming.
Object Initialization
To create a new object, use the new statement to instantiate a class:
<?php class test { function checkTest() { echo "Doing Test."; } } $bar = new test; $bar->checkTest();<br ?--> <?php class test { function checkTest() { echo "Doing Test."; } } $bar = new test; $bar->checkTest(); ?>
By far the easiest and correct way to instantiate an empty generic PHP object that you can then modify for whatever purpose you choose:
<?php $Object = new stdClass(); ?>
I had the most difficult time finding this, hopefully it will help You guys!
Read more OOP in PHP
I hope its helpful for every one, contact & ask any question on http://fb.com/smartwebcareindia