OOP in PHP: The Weird Parts

Why is PHP so Weird?


Object-Oriented Programming in PHP

PHP is a very weird language, particularly with all its callback functions, reflection and magic method features. It tends toward stringly-typed code, making JavaScript look sensible and straight-forward. (It really isn't.) What's the point of implementing Object-Oriented Programming (OOP) features like class member access modifier keywords (public, private and protected) if you're also going to implement two complex, complicated, cumbersome, verbose and weird means of overriding that? (Reflection's cool in theory, but I've never had a practical use for it in all my long years as a Web developer.) Magic methods just make me go "Gah, why?" It doesn't make any sense to me why anyone would do that, let alone why they'd want to. It just seems like a waste of time and effort, for absolutely no practical value. Why not just make everything public and be done with it?

It's no wonder that a lot of the code written in it by beginners is a completely confusing mess!

How do you rate this article?

5


Great White Snark
Great White Snark

I'm currently seeking fixed employment as a S/W & Web developer (C# & ASP .NET MVC, PHP 8+, Python 3), hoping to stash the farmed fiat and go full Crypto, quit the 07:30-18:00 grind. Unsigned music producer; snarky; white; balding; smashes Patriarchy.


Return to the Source
Return to the Source

Use the Force; read the source! This blog is mostly a collection of study notes on ASM, ASP .NET, Blender, BASIC, C/C++, C#, ChucK, Computer Architecture, Computer Literacy, CSS, Digital Logic, Electronics, F#, GIMP, GTK+, Haskel, Java, Julia, JavaScript (ES6+) & JSON, LISP, Nim, OOP, Photoshop, PLAD, Python, Qt, Ruby, Scheme, SQL (MySQL & SQLite), Super Collider, UML, Verilog, VHDL, WASM, XML. If I can learn it and make notes on it, I'll write about it. || Blog images copyright Markus Spiske and Pixabay

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.