anti patterns - What are the PHP-specific antipatterns that you know of? -
PHP as a blunt instrument
I have heard that PHP has recently got a lot of Getting around. In quite a few projects, I have seen the crazy PHP code base - so bad you are really surprised that if the person writes the code, then he was on brain-related drugs. Occasionally, I wonder what the code would be like if there were some more guidance from beginners developers that not to do
However, I have seen some well in 100% OOP and had a pleasure to maintain, but they were not written by "php programmer".
I give a link to all of my junior devs. One of the good things about that page is Java-specific example because there are many features of Java that lend themselves to common mistakes. We were hoping to find a similar list for that, but a Google search did not reveal anything worthwhile.
There are already some questions, but I wanted to focus on the negative.
What is the common thing you should see in PHP and what is a common solution to do better in the same way?
I have some clear examples that I think will be mentioned, but PHP is not specific:
- Do not include SQL statements or use a suitable escape Please.
- Do not embed HTML in PHP with template - Use templateting / MVC.
- Do not post raw unrelated user input - clean it for XSS attacks.
- Do not try to parse all your posts and GET manually - use the web framework.
Here are some examples that I consider PHP specific:
- There are not many layers of file / are required to be added and avoid conditional linking Try it Instead, name a denomination of your name and stay in line with your organization.
- Do not use PHP's raw database API unless you help it, instead use a database structure.
So, what is your favorite PHP? Try the dynamic typing of PHP / PHP in one place and set one bullion elsewhere in the string, and expect the boolean test.
Do not and how do you correct it?
I disagree with this one:
- PHP in HTML Do not embed indiscriminately - use templating / MVC.
PHP is a templateing language . While I agree with the concept of implementing MVC, I do not think there is a need to implement another DSL during preparation of web output.
Comments
Post a Comment