Two of the PHP gossip

Source: Internet
Author: User
Tags goto php language
PHP5.3 's official release has renewed its focus on the language itself. Attentive friends may find that PHP5.3 adds a goto statement, which seems to be a bit of an incredible thing in structured language today.

According to the official statement, this is actually different from our traditional understanding of Goto. The goto statement in PHP 5.3 can only jump in the script file and in the context, so it can't jump from one function or method to another, which has to make me wonder if it's the result of compromise.

It seems that the PHP designer's application of goto statements is easy to jump out of multiple loops (as illustrated by the examples in their documentation). But in fact this function itself has caused a lot of controversy, the individual also vaguely smell the perfume of Pandora's body.

In fact, "good people" in 2007 began to "look forward to" the "new feature", I believe he will be very happy now. But the interesting thing is that the message from this article poured cold water on the original author. Indeed, the functionality that a goto statement can accomplish, in fact, can be done with switch, and more readable.

But in any case, the language itself is merely a tool. From the point of view of the program itself (not just PHP), if there are too many loops and so on the block nesting, it means that the code must be optimized. In the end should not use GOTO statement, in fact I and other PHP personnel have also discussed.

In the end, a more unified view is to avoid use.

"10 Deadly Sins of PHP"

The foreigner is really very unbearable compared to the real, this does not have the good person to summarize the PHP language own grammar "10 sins". In fact, I personally this is called "mistake", also said is the "beautiful trap" provided by PHP.

For example, the variable escape problem for single and double quotes is mentioned in the article. In fact, the voice of the debate from learning PHP from the ears flooded. Even remember when there is a classic face test, that is, the speed of single quotes and double quotes is faster-looking back, this argument is like this one, is not any significance.

But this does not mean that some of the "mistake" can be used as a joke, and some of them really need attention. For example

The following are the referenced contents:

$i = 0;
while ($i < 20); {
Some code here
$i + +;
}

This way of writing. In fact, there is a for statement, we may "hand-mutilated" more than a semicolon (do not admit), then we can only pray set_time_limit the number of smaller.

Other issues that we need to include in our thinking, such as the caching of database access. Why PHP does not have the concept of a data pool so far, it needs to start with the design philosophy of the PHP language itself. From this issue can be extended to argue why PHP does not go to Java routines, well this question can be debated again.

There are other similar entries in the article, which are very controversial (perhaps this is the original intention of the author), but in any case, some of its questions are worthy of our thinking.

Late-night gossip, confusion of the place of the Sirs laughed at, welcome to express your views.



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.