Old webmaster talking about the advantages and disadvantages of PHP code

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Good PHP code should be structured; good PHP code should be standardized; good PHP code should be adaptive; good PHP code should be safe ....

I'm interviewing at SitePoint. The question is: What do you think the pros and cons of PHP code are? Because it gives me a general idea of what kind of programmer a candidate is, rather than simply examining his mastery of PHP functions (which Zend PHP certification, Yahoo's PHP programmer face test questions also belong to this category.

The important thing is that this question lets me know if the candidate has been through a messy code from a lazy programmer, or to help other members of the team deal with this sort of thing.

Admittedly, I don't have a satisfactory answer to this question, but I know which answers I want to hear:

Good PHP code should be structured. Large chunks of code should be split into functions or methods, while small pieces of code that are not Baken should be annotated so that they can be used later. And should be as far as possible to the foreground code such as HTML, CSS, JavaScript, etc. from the program to separate. The Object-oriented programming features of PHP can help programmers organize code well.

Good PHP code should be standardized. Whether it's a naming convention for variable names and function names, or a standardization of some reusable processes such as database operations and error handling, or simply to how well the code is indented, these normalization can greatly improve the readability of your code.

Good PHP code should be adaptive. PHP has a number of features such as magic quotes and short tags, and these features are turned on and off to affect the program's operation. So a good programmer should add the appropriate statements in his code to enable the program to adjust to the environment.

Good PHP code should be safe. Although PHP is an efficient, flexible language with no fixed framework, it leaves the security issue to programmers. A deep understanding of potential security vulnerabilities, such as Cross-site scripting attacks (XSS), cross-site request forgery (CSRF), code injection vulnerabilities, character encoding loops, and so on, is critical for today's professional programmers.

When a candidate answers these questions, I know clearly whether to hire him or not. Of course, sometimes programmers don't do a good job of explaining the problem, and then we ask them to do some PHP testing. Many of the problems in the test seem simple on the surface, but it also gives candidates a chance to show themselves because if you look carefully, you can find the problem. This is also the problem that I have when I do http://www.nd118.com website.

The following little piece of "bad" PHP code is a simplified test question. This question is like asking: How do you optimize this code?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.