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?

Recommended Answers

All 4 Replies

Your plan sounds about right.

commented: The OP seems quite unaware of what he/she it trying to do, and the response is so incorrect it sounds sarcastic. +0

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.

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.

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 .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.