12 features of the PHP language

Source: Internet
Author: User
Tags php language naming convention number sign

The naming convention is contradictory, version compatibility conflicts with each other,PHPlanguage at all levels gives developers a bizarre and difficult puzzle-that's what we're going to talk about today. We're really right.PHPhated??No, of course not. If that's the case, we wouldn't be using it so widely.Drupal,WordPressand some other similar frameworks. Let's say we really hate it.PHP, then the most direct way is to turn toJavarather than put a word here. But you need to be reminded of your supporters, and don't be so familiar withPHPblind to those flaws.

Conversion headaches

in the use of php during project creation, One of the biggest challenges is remembering when we need to enter and which times need to enter php code. The combination of the two is the php A major selling point of the language, But it is not easy to give full play to its advantages. When we look at a file and focus on the code, the first thing we need to figure out is--those forces we have to font-family from the html > You have to attach great importance to these tags, because only then can we integrate the code with the markup and make it work smoothly. Of course, in most cases it only makes people dizzy.

Tagged maze

It is a mistake to combine server directives with browser tags. InJavain this regard, its research and development team strictly followsMVCmode. The data model is attributed to a file where the layout structure used to control the view is attributed to another file, and the logic used to build the controller has its own attribution file. Separating and isolating these items can make the whole project more organized. But inPHP, the most basic design idea is that the developer shouldHTMLTag is a mixture of the controller logic of the server. Although we are not able to differentiate them-and most of us do-but once we begin to specialize in this task, many friends may ask themselves, "Why do we have to usePHPnot be?"

The inconsistency and particularity of naming convention

Do you know when we need to use the underscore symbol??can see thatBase64_encodeThe underline is used in the method, butUrlEncodeis not. In addition,Php_unameThe underscore is used in this name, and thephpversionis not. Why is that ??has anyone considered the problem ??have you ever editedAPI?

strcmp The function cannot be capitalized, but strcasecmp but yes. In addition, strpos can't capitalize, stripos Yes. In the end is the letter " who can remember so many messy rules

Disastrous sort of

How many sort functions do we need?? Javahas a basic sort function plus a simple interface for all objects. If you want to use other algorithms, you can add them, and in most cases the standard functions are fully sufficient. And inPHPthis way, the sort function alone can list a long list:Usort,Sort,Uksortas wellArray_sortwait(Please note that some of them also need to be underlined). So, please put these on the small book immediately, and pray that they do not confuse the actual use of it.

Open source has certain limitations

  PHP There may be many advantages of open source, but the great features such as caching exist only in the commercial version. Of course, this is the reality of society, after all, Zend need to make a profit. Again, the company needs to support the entire PHP project by selling the best version to a specific user group . Complaining about it is like complaining about the inconvenience of gravity, right but meaningless-the earth is there, and you don't like it at all. Please live rationally, and don't always fantasize that people can live in a utopian open source environment.

A bad name space

Do you have any intention of creating your own function If so, first make sure you want to use php 5.3 php php 5.3 and accept the addition of namespaces, so be prepared for the advent of the "backslash"-an ugly punctuation mark.

A bad type of security

This is a horrible question, let's start with a sample that PHP programmers would like to have:

(string) "false" = = (int) 0

php javascript It also contains a large number of type The same kind of situation that is caused by the conversion. In fact, this line is about: The left is a string and the right is an integer. Only the left and right content are exactly equal. In this way, if you let The designer is responsible for the management, everyone in the world can live in harmony with each other.

Too many choices, too much redundancy

  PHP One of the great features of language is that there are too many things to do and too many ways to do things. The end of each line of the command can be commented by a number sign or a double slash. Both floating-point numbers and double-precision numbers represent the same meaning. Simple designs tend to be overlooked because people like to add their own small features during the code contribution process. It's a bit like relying on the commission system to design, but the committee has never considered the difference.

Weird variable naming rules

It's not a good idea to prefix a dollar sign. It may be mandatory to add the symbol before all variables to make it easier to insert it into the template, but the constant content also needs a symbol like this-why is it not actually used ?

  CPU Resource Scramble

for 32 bit computing devices, Large integer values are always an unavoidable challenge. On the other hand, however, 64 Bit devices are not affected by this, which means that the code is running differently on different devices. You can test it in your own notebook, and I can assure you that it is absolutely true. But once the running platform is converted to a server, the situation will change again. At this point, if you want to reproduce the errors on your desktop, I am afraid the results will disappoint you. The only good news is that 32 Devices will most likely eventually disappear.

sql inject

will sql One of the main forms of injecting this security vulnerability is attributed to php > It's really unfair. People in other languages also inadvertently enter the strange sql php The language makes it easier for the vulnerability to grab data and send it to mysql php

There are too many changes in incompatible style

There are huge differences between versions, and compatibility issues are by no means trivial. Programming languages, represented by Java or JavaScript , are rapidly evolving while sacrificing backward-compatible features. In fact, the problem with old code not running on new devices is not uncommon. But all this is not the same as the PHP situation. In PHP , the differences between different versions are often huge, so you can only pray that your server has installed the correct version, or you can only be aware of serious problems when there is a big problem. All in all, take a first glance at PHP when looking for a project on the server that needs to be upgraded .


12 features of the PHP language

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.