PHP Objects And Why All APIs Are Made With Objects .

Object are used to store and reorganize data. Object-ordinate programming structures found in many programming languages are also evident in PHP; however, in PHP it's not required that you write your scripts in an object-oriented manner. Many PHP scripts are procedural rather than object-oriented.
If you are coming to PHP with background in object-oriented programming, this note will help you to understand the object model in PHP. if you are new in programming altogether, it's important to understand the basics of object-oriented programming, but you might want to gain experience in procedural programming and the fundamentals of the PHP language before you tackle a topic that has entire books written on it.
Creating an Object:
Explaining the concept of an object is a little difficult: it's a sort of theoretical box of things-variables, functions, and forth-that exists in a templated structure called a class. although it's easy to visualize a scalar variable, such as $color, with a value of red, or any array called $characters with three of four different elements inside it, some people have a difficult time visualizing objects.
For now, try to think of an object like a little box, with inputs and outputs on either side of it. The input mechanisms are called methods, and methods have properties. Throughout this note, we will look at how classes, methods, and properties all work together to produce a various outputs.
Code, Changing Object Properties:
class myCar {
var $color = "silver";
var $make = "Mazda";
var $model = "Porege5";
}
$car = new myCar();
$car -> color = "red";
$car -> make = "Porsche";
$car -> model = "Boxter";
echo " I drive a: ".$car -> color." ".$car -> make." ".$car -> model;
?>
If you save this code as objpropraties2 .php, place it in your document root, and access it with your web browser, you will see the following on your screen:
I drive a: red Porsche Boxter
The last code show that as long as you have a well-defined class with properties, you can easily change the value of these properties to fit your won needs.
Why APIs Are Made With Objects:
The answer is to keep the main code secure as you can saw you can put functions inside the objects so you can call them in any page without see the main source code
---------------------------------------------------------------------
I will talk about the methods in another note so wait me and if you have any Q just send me message.