If you could remove one feature from PHP so as to discourage, prevent or otherwise help stop newer programmers develop bad habits or practices, or, to stop them falling into traps that might hinder their development skills what would it be and why?
Now, before the votes to close it's not as open-ended as you might think.
I'm not asking purely what is the worst feature or what feature would you really like to remove purely arbitrarily. Yes, there may not be one correct answer but I suspect there will be many similar answers which will provide me with a good idea of things I might be doing wrong, even inadvertently.
I vote for the weak dynamic typing, which I would replace with a strong static typing. That would help so many people, and not only the newbies...
Edit due to comments :
Yes I would replace the typing. Strong static typing, like you can find in other langages like Java/C# brings so much more security, and amazingly increase readability of your code. Let me explain :
//Usual code anyone can have
function myFunction($arrayOfInts, $string)
{
if( !is_array($arrayOfInts) )
throw Exception();
if (!is_string($string))
throw Exception();
foreach($arrayOfInts as $supposedInt)
if ( !is_int($supposedInt) )
throw Exception();
/* Only now is business code. Oh wait no, you need to ensure
that these parameters follow your business rules (e.g. : $supposedInts < 5, etc..) */
}
//More readable code :
function myFunction(Array<int> $arrayOfInts, String $string)
{
//Easier no ?
}
And i don't even talk about the security. So many bugs/errors happend because using an empty string as parameter for a mathematic function...
Still think it would be bad ?
Almost all of php.ini
. There's no reason for 90% of the options to be in there, especially the ones that involve autoescaping of input.
This might be a weird choice, but if I had to choose one feature that trips up the greatest number of newbies, I'd say INCLUDE_PATH
.
Experienced software developers are familiar with pathlike structures. There are search path features in virtually every other programming language and operating system interface: shell PATH
, Java classpath, Perl @INC
, etc. But an amazing number of newbies just don't understand how to use or troubleshoot this very common feature.
For the sake of newbies, I'd force them to write full, absolute pathnames in every call to require
or include
.
I'd remove the current function naming scheme.
mysql_query(), because there are too many bad tutorials out there which never mention escaping. Poeple should switch to PDO and parameterized SQL.