DEV Community

Discussion on: PHP... yay or nay?

Collapse
 
buphmin profile image
buphmin • Edited

PHP is fine. I have been using it for 5 years. My intro into it was with Symfony and a best practice doc so I got to see how good it could be used. PHP has some quirks but overall it is easy to develop with for both web and non-web tasks.

Now the problem with PHP more than some other languages is it's opportunity for abuse. The other day we upgraded to php 7.2 and some things broke. It turns out you used to be able to declare a string and used it as a associative array (hash map).

//please never use this, it is bad :( and will actually not work in php 7.2+
$myArray = "";
$myArray["product_id"] = 12345;

PHP is littered with weird things like this, but ultimately it is up to the developer to not do dumb things.

Collapse
 
vlasales profile image
Vlastimil Pospichal

This code will generate big problems in future. Never use it.

Collapse
 
buphmin profile image
buphmin

I'd never! That does not stop others though unfortunately.

Thread Thread
 
vlasales profile image
Vlastimil Pospichal

Please add comment "Never do this!" into this part of code. Somebody may read this like a pattern.

Thread Thread
 
kevinhch profile image
Kevin

Why this code is bad?

Thread Thread
 
vlasales profile image
Vlastimil Pospichal

String is not an array.