Sinsing on the confusing coding style of PHP

Source: Internet
Author: User
Tags php programming

As we all know, various programming languages have their own style, even if it is like C and C + + Same strain language (C + + is intended to be fully compatible with C syntax), there are some differences in programming style, such as a typical C + + style of single-line comments and C-style multiline comments.

While Java has largely borrowed from C's syntax, it is undeniable that the classic curly brace of Java is that the opening brace is in the same row as the class name or function name, while the C + + style is the curly brace of the other line, which may be used by Java programmers and C + + programmers in both styles. But if you take a look at the master's coding style, you will find that the curly brace of the other line is a typical C + + style, curly braces are not another line is the typical Java style, although these are not essential differences, but like modern people like to shake hands, the ancients like embrace, these habits are very deep-rooted, is rooted in the heart of man.

The following has to say is the PHP programming style, I think many people are learning a lot of programming language, for the coding style also has its own views. Yes, PHP programming style is so confusing, first PHP written in C, a lot of functions directly from the C style, such as curly braces, the end of the semicolon, this is good, after all, C programmers are gray often many, suitable for their study is also very important. Then PHP borrowed a lot of Perl style, the most classic is the $ symbol, at least in my opinion, in addition to Perl and PHP, I really did not find out which language likes to add such a symbol in front of the variable name. Next is its annotation style, the typical shell, C, C + + three styles are supported, this is still very good, not chaotic, at least very classic.

Then have to say is the PHP function name coding style, a word: chaos. If this function is in the class, then we have to consider the hump naming method, such as GetName, for the built-in function, it may be underlined, such as error_reporting, such as Html_entity_decode, It is also possible to connect directly with letters, such as htmlentities, and possibly some shorthand rules, like rtirm and LTrim. To PHP's learning and use has brought a certain confusion.

Finally, the object-oriented PHP, PHP object-oriented to a large extent Java-style, borrowed from Java's single inheritance and interface ideas, so it is particularly suitable for Java programmers to switch to PHP, but also very suitable for PHP programmers to turn to Java.

A little bit of a moment to remember what to say, in short, PHP coding style is a hodgepodge, need programmers constantly to adapt.

Related 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.