Month: October 2013

Creating PHP Object

Many novice programmers want to know what it is OOP?

Well… OOP stands for Object Oriented Programming. And now another question, what does it mean by Object Oriented Programming?

Hm… Let’s start with an example about an object.

Let’s take the example of a car. A car is an object. Isn’t it? Yeah, a normal car generally has a engine, wheels, doors, steering wheel and color. When we make a car park, we will arrange a lot of cars in it. If we create a car with OOP in programming concepts, we will organize them easily. We just need to put a car and calling the property of a car. First car will look like a normally car. Second car without a wheels, third car without windows and so on.

Now, let’s jump into code:

class Car
    function Doors($numCar, $count)
        echo "Car Number: ".$numCar." has ".$count." dor(s)<br>";
            function Color($numCar, $color)
                echo " Car Number: ".$numCar." doors color are ".$color."<br>";
    function Wheels($numCar)
        echo " Car Number: ".$numCar." has 4 wheels<br>";
$car01 = new Car;

echo "<br>";
$car02 = new Car;