Published: 19 June 2014 I know this topic has been discussed many many times, but still I think a lot of developers, just like me until recently, are still not clear what actually is the difference between the two. So I think I’d like to put it into my own words to describe the differences.

To me, procedural programming is really just the act of specifying a set of ordered steps needed to implement the requested functionality, your code could use classes, objects, methods, but if your code is focusing on the processing - the algorithm needed to perform the desired computation. It would still be procedural. For example the following code:

$m = new MySQLi(...);
$res = $m->query($query);
$results = array();
while ($row = $m->fetch_assoc($res)) {    
$results[] = $row;


class GetResults {   
public function getResults() {       
$m = new MySQLi(...);       
$res = $m->query($query);       
$results = array();       
while ($row = $m->fetch_assoc($res))
{           
$results[] = $row;       
}       
return $results;   
}



Is it still considered procedural, not OOP
On the other hand, for OOP, the focus is on data organisation and abstraction. It tries to make us think of our program as interacting concepts rather than as a bunch of data with functions twiddling their bits. The goal is to write programs that scale better and are more adaptable to change.

For example, if we are to code up a system to record data on cars, trucks and buses through forms, if we coded a form builder that would render each form element based on some parameters, and then created an array for each type of the vehicle to define their fields, then call a display function in the form builder code file and pass it the fields array of the vehicle, I would still consider this OOP even if we’ve used no classes, objects.

OOP is a technique for programming, when we say a language is object oriented, that means it provides mechanisms that makes it convenient to use the object oriented style. What actually decides if our code is procedural or OO is our approach towards solving the problem.    

Page Name: {% PageName %}

Page Template: {% PageTemplate %}

CampaignID: {% AgentReferrer.ID %}

CampaignName: {% AgentReferrer.Name %}

CampaignPhone: {% AgentReferrer.Phone %}

Item Location: {% PageLocation %}

Search Session Exists: False