waterfall methodology

The Waterfall Methodology has Helped in The Development of Many Software We Use Today

Many articles online are very informative, and many posts are very valuable, one thing I did learned from this many posts online about waterfall, is that the waterfall methodology, is indeed the...

QUANTUM MECHANICHS

Quantum Computing Will Be Disruptive to The Current System of Computers Available

Quantum computing is not an area, in which I am familiar with at all, I didn’t even know it existed, but when I researched it, I realized that this technology is very interesting to explore.

...
computer systems

The Classification of Standalone Computer Systems, which Exist in the World Today

Symbols can be manipulated through machines known as computer systems, which are functional computers with all its hardware and software, made to help users achieve their goals, complete tasks and...

About The Life Of The Writer

Hi every one, I obtained a bachelor's degree in Bioinformatics back in 2006, from Claflin University, after I received my bachelor's degree, I gained full time employment as a software engineer at...

Robots advenced

A List Of The Most Advanced Robots In Technology Today

We are living in a society, which is growing on a daily basis, because of the type of technology, which we are developing. In today’s article, we are going to talk, about the different kinds of...

Error message

Notice: Undefined variable: front_page in eval() (line 19 of /home/content/93/10477193/html/modules/php/php.module(80) : eval()'d code).

Object Oriented Programming PHP is A Straight Forward Approach to Programming

php oop

The programming world, is very interesting and many people are always trying to sharpen their skills in the area of programming, or they are trying to acquire new skills in programming.

In today’s article, we are going to talk about, the object-oriented programming side of PHP.

Object Oriented PHP (OO PHP), can have the ability to frighten, many PHP developers.

One of the reasons why, many PHP developers, don’t really like OO PHP, is due to the concepts of complicated syntax and other roadblocks, which they can face, during the development life cycle of applications.

Developers who use OO PHP, are able to group similar programming tasks, into classes.

When tasks are grouped into classes, then the code is not going to be repeated, so that you “don’t repeat yourself” (DRY), also developers can easily maintain their code, when using OO PHP.

Another aspect of your code which, OO PHP can help you with, is that, when updates to your code are required, you can easily change the code, in one central place, and this change will affect the entire code or parts of the code.

Duplicated data and functionality, can affect the code, when it is time to update the code, because a developer, would have to search the entire directory structure, for data.

A lot of developers are intimidated by OOP, due to the new syntax, and when you just look at it, it does look more complicated.

However, OOP is not as bad as many developers, may have in their minds, because this style of programming is a very simple and straightforward approach to programming.

Alright now let’s define some terms, which are useful to know, in order to understand OO PHP.

In OO PHP you will find something known as a Class: which is used by developers, to group local functions and local data.

If you want to make many instances of the same class or kind of objects, then a class would be a handy tool to use.

Another term, to know in OO PHP is the Object: which is defined by the class as an instance of the data structure.

Instances or objects of the same kind, are defined within one class, and the objects can be a combination of variables, functions, and data structures.

Another important term is the Member Variable: which is a variable, which is defined within a class.

Once an object is created, these variables are called attribute of the object.

Also the data contained in these variables, are only seen within the class and not outside of the class, where the variable is located.

Another important term is the Inheritance: which is a class, which has been defined, with an inherited existing function, of a parent class.

Functions and variables of a parent class, are inherited, by the child class, in the process known as inheritance.

Another important term is Polymorphism: which is, a concept in object-oriented programming, which allows the same function, to be used for different purposes.

Encapsulation is another important term in OO PHP, and it refers to objects, which shows that all data and member functions are encapsulated to form that object.

Constructor is important as well, because this is a special type of function, which, whenever there is an object formation from a class, then the constructor is called.

Last but not least, is the Destructor which is a type of function, which, whenever an object is deleted or goes out of scope, then the destructor is called.

Defining PHP Classes

The general form for defining a new class in PHP is as follows –
 

<?php class phpClass { var $var1; var $var2 = "constant string"; function myfunc ($arg1, $arg2) { [.] } [.] } ?>