Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

OO PHP

Featured Replies

Hello,

 

I am currently thinking of migrating to an OO coding style when developing in PHP however the only experience I have of OO Development is in Java, this means I have some knowledge of classes, methods, objects and inheritence. However I do not understand how it all works with PHP, I have a decent understanding of PHP. I was hoping someone good guide me to websites, books that could get me started as a newbie.

 

Thank you very much

I found the PHP 5 Objects, Patterns, and Practice book a great starting block for OOP in PHP.

 

It takes a while to get your head around the concept, but seeing as you've dabbled in Java you'll probably pick it up quickly.

What in tarnation is an OO style? Is that like when you're impressed with it and you say 'OOHH, PHP! That looks good'?.....

 

Thought not.

 

Care to share? ;)

Hello,

 

I am currently thinking of migrating to an OO coding style when developing in PHP however the only experience I have of OO Development is in Java, this means I have some knowledge of classes, methods, objects and inheritence. However I do not understand how it all works with PHP, I have a decent understanding of PHP. I was hoping someone good guide me to websites, books that could get me started as a newbie.

 

Thank you very much

I tried out some of PHP's OO features but there were 2 limitations:

  1. PHP OO does not compare with Java or C++ so the benefits are less likely to justify the extra work.
  2. Some of features (like static variables) only work with PHP5 and NOT PHP4. This is a problem since a lot of mature sites (ones that make money) still use PHP4.
  3. Other programmers with no experience of a language like Java are completely confused.

What in tarnation is an OO style? Is that like when you're impressed with it and you say 'OOHH, PHP! That looks good'?.....

 

Thought not.

 

Care to share? ;)

 

OO = Object Oriented

This helps with organising code in large programming projects and should mean less bugs.

You create classes which can have methods and varibles. Then you create objecs which are instances of a class. Then your code can look like this:

$myaccount = new Account('John Smith');
$myaccount->setBalance(1000000);
$myaccount->pay('PayPal', 'me@me.com', 14000);
$cash_left = $myaccount->balance;

It's basically a method of programming that really cuts down the chances of code duplication and overwriting. Plus it sounds funny to say :pp

As a side question, I've just started learning PHP too - which would you recommend learning first after HTML/CSS, JS or PHP?

That completely depends on what you hope to do.

 

Javascript and PHP do totally different things.

 

If you want to develop larger apps with databases etc then you will need PHP, if you are more interested in functionality and adding gizmo's to your site then learn javascript.

 

Personally, I have never "learnt" javascript, I learned PHP by fiddling with code and writing my own bits, and all of the javascript I've ever needed is out there on the web, I know enough to manipulate a similar script to do what I want to do. I find javascript has too many quirks to "learn", I mean I can code in C++, Java, C#, PHP, Perl etc but Javascript (and visual basic for that matter) have always gone over my head in some way...

 

It just NEVER works the way you expect !

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.