Home  >  Article  >  Backend Development  >  What alphabetic characters are allowed in php identifiers?

What alphabetic characters are allowed in php identifiers?

青灯夜游
青灯夜游Original
2019-11-20 18:17:395906browse

What alphabetic characters are allowed in php identifiers?

In PHP program development, it is often necessary to customize some symbols to mark some names, such as variable names, function names, class names, etc. These symbols are called identifiers. The definition of identifiers needs to follow certain rules:

1. Identifiers can only consist of 26 English alphabetic characters in uppercase and lowercase (a~z, A~Z), numbers (0~9), and underscores ( _) and cannot contain spaces.

2.Identifiers can only be composed of characters of any length starting with letters or underscores.

3. When identifiers are used as variable names, they are case-sensitive.

4. If the identifier consists of multiple words, they should be separated by underscores.

5. Predefined keywords in PHP cannot be used

Follow PHP Definition rules for identifiers. The identifiers it, It, it88, and _it are legal, while 8it and i-t are illegal identifiers

PHP variable rules:

Variables start with the $ symbol, followed by the name of the variable, and the other rules are the same as above

Creating PHP variables

PHP has no command to create variables.

Variables will be created the first time they are assigned a value:

Example:

<?php
$txt="Hello world!";
$x=5;
$y=10.5;
?>

Recommended learning: PHP tutorial

The above is the detailed content of What alphabetic characters are allowed in php identifiers?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn