Avoid using PHP reserved words as constants, class names, and method names, as well as the naming of namespaces

Source: Internet
Author: User

http://php.net/manual/zh/reserved.keywords.php

These words have a special meaning in PHP. Some of them are like functions, some like constants ... But they are not, they are only part of the language structure. You cannot use any of them as constants, method names, or class names. However, they can be used as variable names, but this leads to confusion.

Starting with PHP7.0.0 These keywords allow to be used as the class's properties, constants, and the class's method name, or interface name and traints name, except that class cannot be used as a constant name.
PHP keyword __halt_compiler () abstract and array () as
Break callable (as of PHP 5.4) case Catch class
Clone Const Continue declare default
Die () do echo Else ElseIf
Empty () Enddeclare endfor Endforeach endif
Endswitch endwhile eval () exit () extends
Final finally (starting from PHP 5.5) for foreach function
Global Goto (starting from PHP 5.3) if implements include
Include_once instanceof insteadof (starting from PHP 5.4) interface Isset ()
List () namespace (starting from PHP 5.3) New or print
Private protected public require require_once
Return static switch throw trait (starting from PHP 5.4)
Try Unset () use Var while
Xor yield (starting from PHP 5.5)
Compile constant __class__ __dir__ (starting from PHP 5.3) __file__ __function__ __line__ __method__
__namespace__ (starting from PHP 5.3) __trait__ (starting from PHP 5.4)

Avoid using PHP reserved words as constants, class names, and method names, as well as the naming of namespaces

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.