---
title: 'Should You Learn Object Oriented PHP?'
source: 'https://youtube.com/watch?v=8yW0zxhO89g'
video_id: '8yW0zxhO89g'
date: 2026-06-15
duration_sec: 0
---

# Should You Learn Object Oriented PHP?

> Source: [Should You Learn Object Oriented PHP?](https://youtube.com/watch?v=8yW0zxhO89g)

## Summary

The video compares procedural and object-oriented PHP, explaining their differences, pros and cons, and arguing that neither is inherently better; the choice depends on the project's complexity and scalability needs.

### Key Points

- **Introduction to the debate** [0:00] — The creator addresses comments debating whether object-oriented or procedural PHP is better, noting that both styles have their place.
- **Visual example of procedural vs OOP** [1:07] — Shows a basic login form example: procedural uses functions in separate files, while OOP uses classes with properties and methods.
- **Procedural approach explained** [3:14] — Procedural code has one file handling the request and another file with functions for authentication, reusing code via functions.
- **Object-oriented approach explained** [3:30] — OOP uses a class file that encapsulates properties and methods for login, allowing instantiation of objects with specific data.
- **Benefits of OOP** [6:18] — OOP provides encapsulation, code organization, scalability, and the ability to restrict access to sensitive code via class inheritance.
- **Why some prefer procedural** [6:57] — Some argue procedural is simpler, less complex, and easier to read for small projects; OOP can overcomplicate simple tasks like a contact form.
- **Context matters** [9:00] — The choice depends on the application: for complex, scalable projects, OOP is beneficial; for simple, one-off features, procedural is sufficient.
- **Pros and cons summary** [10:04] — OOP has a steeper learning curve and slight performance overhead, but offers better organization and scalability. Procedural is simpler but less maintainable for large projects.
- **Common criticisms of OOP** [11:20] — Critics say OOP code can be harder to read if not well-organized, and splitting code into many files can be confusing for beginners.
- **Final advice** [12:28] — There is no 'better' paradigm; consider the project's future scalability and choose accordingly. The creator offers both procedural and OOP PHP courses.

### Conclusion

Neither procedural nor object-oriented PHP is universally better; the choice should be based on the project's complexity and scalability requirements.

## Transcript

so occasionally I do get comments
discussing whether or not object or into
PHP is better than procedural PHP and
this is something I will get because I
do have a optic oriented PHP cores and I
do also have some project videos where I
have a object-oriented version and I
have a procedural version and sometimes
I get people jumping into one of those
project videos not really to watch the
video but to let everyone know that you
should not learn after you go into PHP
so figured why not do a short video just
kind of going over what exactly are some
of the benefits and you know we call
those pros and cons when it comes to
learning object-oriented PHP versus
learning procedural PHP what exactly is
the difference between procedural and
object under PHP and is it something you
should learn you know what are the pros
and cons to learning each of these
different styles of coding and of course
there's going to be a lot of people
watching this video who do already have
a lot of years of experience when it
comes to optic oriented versus
procedural and just knowing the
differences but there's also a lot of
new people watching so I figured why not
just do one for them you know so they
know a little bit about okay so there's
something called procedural there's
something called object oriented and
should you listen to people who tell you
not to learn object oriented like what
exactly is that all about so the first
thing I want to point out here is well
point out I can actually show you
because I set up this very basic example
here but as you can see inside my code
editor here my my visual studio code I
have a example of using procedural PHP
and I do also have an example using
object-oriented PHP and these are very
very bone examples okay again it's just
an example to kind of prove a point here
so the code inside my editor is not
going to make any sort of sense it's not
going to do anything it's just so that
beginners can see the difference when it
comes to the visuals of how procedural
looks like when it comes to object
oriented okay so inside my editor here I
do have an example of procedural
programming and again this is going to
carry over into JavaScript if you're
interested in JavaScript so again it's
just basically procedural versus object
oriented it doesn't really matter with
the language itself so inside my editor
I have a index page and inside my
website I would like for a person to go
in and be able to type in something
inside this particular input here in
this case it's just a username and a
password and that basically means when
they type it in they're going to send
this information to another page inside
our website in this case here I'm
sending it to a
formhandler.ink.php and if I were to
take a look at that page you can
actually see when it comes to procedural
PHP again PHP in this example here if I
were to go in here you can see that we
basically just go in we check for a
request method to make sure that this
was submitted by a form then we go down
we grab the data and then we actually do
something with it in this case if you
authenticate the user by doing a
authentication function that we have
somewhere inside our code and that code
could for example be inside a file
called login.link.php which basically
just have a basic function that goes in
and does some sort of authentication
again the code doesn't make any sort of
sense but just to kind of show how we
split up the tasks inside our code into
different functions maybe inside a
separate page so that we don't have to
to rewrite code all the time and we can
reuse our code and it's just a much
better solution so that's why we use
functions inside our code again this is
very basic programming this is something
you'll learn almost immediately in any
sort of course so the basic idea here is
that you have this one file that takes
care of the actual request from the user
in this case you're logging in into the
website and then you just have a
separate file that has a bunch of
functions that might be related to a
login system so that is how you would do
that but when it comes to optic oriented
PHP you would do it slightly different
so if I were to go inside my object or
insert example here and go inside my
formhandler.ink.php you're going to see
that it looks a little bit different we
do still go inside and check is this
actually accessed by posting the login
form and if so then we go in and grab
the data but then we also go in and we
want to include a file which is going to
be a class file so in this case you're
not a file that is full of functions but
a class that has login specific
properties and methods so people who's
never done object oriented before
properties and methods are kind of the
same thing as a variable and functions
but not quite but just to give a very
what should you say like comparative
thing to make people understand what
exactly it is that is what we're going
to pretend it is and this particular
class file is going to look something
like this so we go inside a another file
and instead of having a bunch of
functions we actually have a class which
is going to encapsulate a bunch of
properties and methods that has a
specific purpose so in this case here we
have a property or we have two
properties actually these are called
Fields if you have to be very specific
here then we go in and we actually say
we want to assign some data to these
fields so when we actually call upon
this class here and create a object
based off of this class or this
blueprint we have here then we can
assign data to the object by passing in
data into the class when we actually
instantiate it and then we have a method
inside the class itself that is kind of
like a function again just to use some
comparative words for people who's never
done it before to understand what this
is this is kind of like a function where
you go and then you just do the
validation and authentication like you
would inside that other function inside
the previous example so what you then do
inside the form Handler when you call
upon this file is to create a object
based off the class because a class is a
blueprint where we can create a object
that has all the information that is
inside this class but the object is
going to change depending on what we
pass into the class when we actually
instantiate this class here this is not
supposed to turn into a tutorial annual
okay we're not we're not supposed to
teach about classes in this video but
just to give an idea about how it is
different so basically instead of having
just a bunch of functions inside a file
where the file is named according to
what the functions are supposed to do so
all of a sudden we have all these
different files with different functions
in it we instead create a class file
that has properties and methods inside
of it that has basic information about
this particular feature you might have
inside your website so you can have a
you can have a class here in this case
we could call you so we could also call
it login so it's more specific to the
login system where you just basically go
and you have all this information like
typically would with functions as well
inside this class here but now using
classes is also going to give you a
bunch of different good things about it
for example that you encapsulate all the
different you know features that you
have inside all the different code into
different classes that can then extend
to each other in order to only be able
to access certain classes if it comes
from another class which means that we
can take more sensitive code and put it
inside a sensitive class that should
only be accessible to certain other
classes and in disorder sense when we
have very sensitive code we can make
sure it only gets run under certain
conditions where some classes can access
it so like there's a bunch of things
here when it comes to classes and I can
talk about this forever but there's a
lot of benefits to using optic or into
PHP versus procedural PHP so why do
people not like object oriented PHP
versus procedural why do some people
fight so heavily for doing procedural
PHP inside a website I think the first
thing that needs to be pointed out here
is that the mindset of having procedural
PHP being better than Arctic down to PHP
or object or into PHP being better than
procedural PHP is kind of a wrong
mindset to have I can completely
understand that some people they have a
preference to watch one or the other but
it is also important to keep in mind
that these are just tools that are used
in order to do something inside your
application in this case here a website
so in some cases where you might have a
certain website that only needs one
little feature using PHP for example
just a contact form you know of course
you wouldn't be using object or into PHP
in order to do that because it is just a
contact form there's no extensive
features that are planned in the future
so there's not really any reason to over
complicate the code and that's really
one of the key points that I also have
to talk about when it comes to optic
oriented PHP because yes object oriented
PHP is much more complex than just doing
procedural for the beginners watching
this video essentially what procedural
is is when you have a place inside one
of the pages inside your website where
you need a certain piece of code then
you go into that place inside the page
for example inside this index page here
let's say I need to add a contact form
at the bottom here I would just go in
create my PHP tags and I'll just start
creating all the code for my contact
form that is a procedural PHP mindset
but when it comes to object oriented PHP
we all of a sudden take this code and we
split it apart and we encapsulate it
into different files and different
classes and all of a sudden we have many
different codes spread out all over the
place which is going to make things a
little bit more organized and scalable
when it comes to larger applications but
when it comes to just a small feature
like for example a contact form yes you
should most likely not over complicate
things by spreading everything out into
different classes so there is no such
thing as procedural PHP or Optic or into
PHP being better than the other you have
to look at the specific application
you're sitting with and from that you
can determine is one of them going to be
better because yes for example when it
comes to a login system I think
personally we're moving into a area
where it gets a little bit more complex
with the PHP application what we need to
make sure that we can actually scale
things properly and have everything
organized when it comes to the code so
in those sort of situations I do not
think that procedural PHP is going to be
a benefit because now we're moving into
a more complex PHP application for your
website in order for more advanced
features when it comes to using a
back-end language inside your website
and yes there is pros and cons when it
comes to using both procedural and
object-oriented php's I can for example
give you a small list here of things
that is pros and cons to both of them so
again it really depends on the
application you're sitting with and you
have to determine which one is going to
be better for your particular project
for example if you have a certain
application that is going to have a lot
of performance critical applications
inside of them then you may consider
some aspects of your application being
procedural Sims object oriented is it
slightly more complex when it comes to
Performance so again there is pros and
cons for both different types and you
have to look at the individual thing or
the the thing the application you're
sitting with and of course that is not
going to stop people from just being
heavily biased when it comes to for
example being against or for object
oriented PHP people will still come
inside some videos or maybe underneath
this video here heavily arguing for why
object oriented PHP is just complete
garbage or why procedural PHP should
never be used and this opinion can come
from many different reasons for example
some people just think the learning
curve to learn object or into PHP is too
big and they don't want to get into it
because it's very complex which is going
to lead to some biased opinions when it
comes to you know arguing against optic
oriented PHP we do also have people who
just thinks that it is much more complex
when it comes to optic oriented PHP
because the code all of a sudden gets a
little bit more less hard to read if
you're not careful about it you need to
make sure you organize things properly
inside object or into PHP to make sure
the classes make sense and there's
comments explaining what exactly things
do because when you start taking apart
code and splitting it out into different
files and different classes you need to
make sure that there is a system going
so people can actually look look at
these and understand where the code is
and to some people this organization
here or the mindset of splitting things
into different files instead of just
having everything in one place is going
to be something to have a hard time
grasping because if you have to be
honest here I can see where that opinion
is coming from I can definitely see how
a certain mindset where you say okay
well I need a contact form right here so
therefore this is the place inside my
website inside that particular file that
I'm going to put my PHP code for that
particular application so all of a
sudden when you start splitting code
into different files all of a sudden
you're going away from this very simple
mindset of this is where the code needs
to be so therefore this is where it is
going to be inside my file to okay so
now we have a file for contacting the
database and we have a file for
performing actions when the user submits
data and then we have another file
that's showing something inside the
website all of a sudden we have all
these tasks split out and that can be a
hard thing to grasp especially as a
beginner some people are also going to
give more geeky
key
technical concerns about object-oriented
PHP which could for example be
performance because yes optic run to PHP
is slightly more performance heavy when
it comes to the code because there's a
encapsulation and you have to
instantiate classes and that kind of
thing so again the important Point here
that I'm trying to make is there's no
such thing as one of them being better
than the other it is much about what
exactly are trying to build inside this
website here and do you actually plan
for this to be more scalable in the
future do you plan to add more features
to this website because if you do then
maybe you should start out with object
oriented PHP so you do have a
foundational system that you can
actually build upon in a much more
practical sense so again just a small
rant here to give my personal take on
this because I do know that a lot of
people have a very strong opinion about
one or the other and I do see a lot of
these opinions a lot inside my videos
which by the way small advertisement
here I do have a object oriented PHP
course and I do also have a procedural
PHP course which I just updated so if
you're interested in learning PHP I do
have different
what is it called playlist that you can
watch so we do have something inside
this channel here that is going to be
very beneficial for people so with that
said I hope you all enjoyed this video
here and I'll see you guys next time
foreign
[Music]
