How can I write PHP code to be hired?

Source: Internet
Author: User
Tags echo command

Kevin Yank was an interviewer at SitePoint. he published a Good and Bad PHP Code and elaborated on his views on the merits and demerits of the PHP Code through some Code examples. There are several simple things mentioned here:

<? Replaced with <? Php, which is more in line with XML specifications.
Determine whether it is null before outputting the value of $ _ GET [query.
The extra parentheses in the echo command are removed.
The string is limited by single quotes, saving PHP time to search for replaceable variables from the string.
Use commas instead of periods to save the echo time.
Pass the ENT_QUOTES identifier to the htmlspecialchars function to ensure that the single quotation marks are also escaped. Although this is the most important thing, it is also a good habit.
Many PHP users are familiar with these writing rules, and these writing rules seem very idiotic. However, it took three months for them to recruit programmers who met the above conditions and satisfied them.

Not every company needs to hire programmers like this. But how to develop a good habit may be something that many programmers need to do most, including N + masters. If you are interested, you can view mint brain's full-text translation of this article.

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.