Petter Kjelkenes, a blog about technical stuff.
PHP is probably amongst the most hated programming languages around the world. Some people love it, some people say its a toy language, some people hate it with a passion.
PHP has grown a lot within the last couple of years. PHP now supports proper OOP, and have concepts like Classes, Interfaces, Traits, Closures / lamdas, Generators, Strict types, and more.
This article will be a list of what I think is good, and what I dont like about PHP.
Global function mess.
PHP's mess around global functions can be frustrating.
<?php $array = [1,2,3]; // Can just this: $array = array_merge($array, ); // Be this? $array->merge();
Dollar signs $ :(
Dollar sign in front of variables shouldn't be necessary. I would rather use literals to concatenate.
Because PHP is so simple by default, it doesn't have good defaults for security such as XSS injections.
<?php $opsIForgotToEscapeThisVariable = $_GET['xss-attacks-are-welcome-here']; echo "Hello $opsIForgotToEscapeThisVariable";
Too easy to learn.
I mean it. Its way too easy. PHP is so easy to learn, which leads to really bad code written by junior developers which just started learning to code.
I did not sign up for Java
I dont like Java. Actually I dont like Java at all. PHP is starting to feel more like Java. This can be great, but often leads to overly complex code. E.g. use a simple array instead of creating 10 value object classes that implements each of its own interface?
When working with PHP projects you would often work with legacy code. This legacy code was e.g. written by really bad programmers or was written for PHP 4 with no OOP at all. Working with such code makes you feel like a sad -sad Panda. Often these systems are also full of bugs.
Legacy code can be true for other programming languages as well. But I solely think PHP has the worst legacy code. PHP 4 was really bad and the eco system was not there.
My name is Petter Kjelkenes. I live in a small country named Norway.
I am a full-stack developer, mostly using tech like: PHP, Symfony, Node.js, React and CMS tech like eZ Platform + sanity.
(+47) 482 913 65