0

PHP Objects And Why All APIs Are Made With Objects .

Posted by Ahmad on 1:40 PM

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.

0

What is PHP?

Posted by Ahmad on 1:16 PM



PHP is a scripting language originally designed for producing dynamic web pages. It has evolved to include a command line interface capability and can be used in standalone graphical applications.[2]

While PHP was originally created by Rasmus Lerdorf in 1995, the main implementation of PHP is now produced by The PHP Group and serves as the de facto standard for PHP as there is no formal specification.[3] PHP is free software released under the PHP License, however it is incompatible with the GNU General Public License (GPL), due to restrictions on the usage of the term PHP.[4]

PHP is a widely-used general-purpose scripting language that is especially suited for web development and can be embedded into HTML. It generally runs on a web server, taking PHP code as its input and creating web pages as output. It can be deployed on most web servers and on almost every operating system and platform free of charge.[5] PHP is installed on more than 20 million websites and 1 million web servers.[6]