
What are the worst parts of PHP? - justinzollars
Would you ever consider a job in PHP? Are the worst parts of PHP blockers for you? Tell me about your experiences!
======
smt88
Worked on PHP on-and-off for more than 15 years. Jobs in PHP can sometimes pay
well, but the PHP labor market is fairly saturated, so you're more likely
getting underpaid than well-paid.

Here are some of the reasons I don't use PHP anymore:

1\. Code bases often written by near-amateurs, so almost always a headache to
work on

2\. Terrible type system (and unpredictable type coercion) mean that the code
has to be written with great discipline or it's going to be buggy

3\. Inconsistent signatures of built-in classes/methods/functions means that
it's almost impossible to remember anything, so you need to consult
documentation (or inline completion) constantly

4\. Very generally, a community that likes magic (see: Laravel) -- ease/speed
is prioritized over correctness/explicitness, which means maintaining large
PHP projects is often a nightmare

~~~
ccajas
Irony, thy name is PHP. Your name means "hypertext pre-processor" and was
conceptualized first and foremost to be a web dev language. But you're now
often being turned down in the web dev world in favor of general-purpose
languages!

~~~
smt88
The web is used radically differently now than it was 22 years ago in 1995.
Also, PHP wasn't designed to be the platform for large code bases maintained
by multiple people. It wasn't really designed at all, as its creators have
said publicly.

------
krapp
>Would you ever consider a job in PHP?

Heh. Most of the programming work I get is with PHP. I wish I could find work
_not_ in PHP. I'm still paying off a degree for building business applications
in C# - and trying not to forget C# because I never use it. I can't seem to
get a chance to forget PHP.

To me, the worst parts of PHP are, first, that the language was designed and
intended to be used the way Wordpress (and many small hacky sites) use it -
with PHP, HTML, Javascript and CSS all mixed together.

And second, that PHP isn't aware of context - it doesn't treat XML as objects
(the way Hack does with XHP) and doesn't escape variables by default. One
either has to manually escape every instance of every variable with a function
whose name is too damn long (htmlspecialchars) or use a framework which does
that for you.

The second point entirely undermines the purpose of PHP, and turns the first
into an utter minefield.

~~~
dreistdreist
Automatic escaping would not work anyways, you need to escape for the
appropriate context (HTML, JS, CSS, JSON, XML...).

You don't have to use a framework, just use one of the many composer packages
available like Twig for example...

------
dreistdreist
I am working on a nice PHP 7.1 codebase where we just started with DDD. It's
awesome.

Yeah there is quite a bit of legacy code still there (the application is over
a decade old), but all the new OOP code is nice to work with and we are
getting rid of the old one slowly over time.

------
dpeck
the parts after "<?php"

Seriously though, I would think long and hard and be unlikely to take a job
requiring more than a trivial amount of php. For me its tough to structure
well, the stdlib is inconsistent so it means constantly having to look at the
documentation, etc.

------
jamesmp98
Are we talking about modern PHP or pre-PHP7?

~~~
justinzollars
Lets say both, I'd like to hear your perspective.

------
sbank
PHP.

~~~
justinzollars
I didn't get the job so I should be thankful!

------
vgy7ujm
In many ways OO PHP is starting to look a lot like Java. Verbose and
overarchitected code. It was a good templating language for C modules, not so
good when you try to shoehorn it into solving every problem that you have.

