954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Object oriented coding in PHP

ive been coding the plain old procedural way in php and i want to move that code to object oriented.
can i just simply use my currently written php code into a function and then call it?


pleas let me know an easy way to make my normal php code into object oriented?

rukshilag
Junior Poster
101 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

Your plan sounds about right.

JRM
Practically a Master Poster
621 posts since Nov 2006
Reputation Points: 130
Solved Threads: 75
 

I would start over.
Try make a general library with things you need like a database class, its great practice and will help speed up future projects.

Philip435
Newbie Poster
17 posts since Nov 2009
Reputation Points: 10
Solved Threads: 1
 

A class is a group of php code that you can use to create a massive set of data you write it the same way you do php code with a few exceptions.

class First(){

 $this->text = "My First class"

}

//and you call it like so,

$firstclass - new First();

//echo "My First Class";
echo $firstclass->text;


in the class you can add any number of php code and functions and put the data in $this->variable.

liamfriel
Junior Poster
103 posts since Oct 2009
Reputation Points: 13
Solved Threads: 13
 

In PHP the concept of OOP is less code there is just a logic of this concepts . There arfe some data types of OOP are using in PHP code there might be use of inheritance and abstract concepts are using for the PHP level for coding . For PHP the logic must be clear other wise you cant do the coding .

jenyroger
Newbie Poster
3 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: