Top 3 most common PHP errors
In a DHTML platform such as PHP, the most common programming errors which are truly difficult to even notice are those which are related to variable declaration and certain operations. Here’s a list of them which I personally experience the most:
- Conflicting variable names - This one’s a pain in the neck. Since PHP’s way of declaring, assigning, and calling variables are similar, there’s no way it can prompt the programmer that there’s already a variable in conflict with a previous declaration. For example, variable "$var" is declared and initialized as "$var = null;" Later, even if you have in mind declaring another variable and you forgot that you already have "$var" in the earlier part, a statement such as "$var = true;" won’t be considered a declaration, but rather, an assignment. Which means, it’s value is changed from "null" to "true".
- Appending an operation to a string - Producing a string wherein a part of it is a result of an operation such as this: "$str = ‘Hello ‘ . 1 + 25 . ‘ World’;" doesn’t work, but this will: "$str = ‘Hello ‘ . (1 + 25) . ‘ World’;" If you are to append or include a mathematical operation in a string, it should always be enclosed in parenthesis. Well, anyway, in programming, the use of parenthesis in any statement is always a recommended practice.
- Missing the $ sign - Upon calling a variable for a certain operation, PHP does not generally produce an error for variable typos without the "$", and it’s pretty difficult to detect, because it would seem it doesn’t have any problem, but actually, it’s a very big problem. I believe, once an undeclared variable without the "$" is being called, it is considered as a literal string or a number.

