What does a php variable name consist of?

(*-*)浩
Release: 2023-02-26 10:08:02
Original
4053 people have browsed it

What does a php variable name consist of?

Naming rules for php variables

PHP variable names cannot be randomly chosen and must follow the naming rules for php variables, as follows: (Recommended learning:PHP video tutorial)

a. It must start with a dollar sign ($), such as: $a, $b;

b, dollar sign ( The first letter after $) can only be an underscore "_" or a letter, not a number (for example: $3a is illegal);

c, the part after the dollar sign ($) can only be It consists of letters, underscores (_) and numbers;

Note:

php variable names are case-sensitive, for example: $name and $Name are two Different variables;

The naming of php variables is generally based on the meaning of the name, and is named using English words. If it consists of more than one word, capitalize the first letter of each word except the first.

Declaration of php variables

The declaration of php variables is very simple. Since php is a weak language, there is no need to specify the variable type when declaring variables. Its PHP variables can be used without declaration, and are automatically declared when used.

As shown below:

Calculate the sum of variable $number1 and variable $number2

Copy after login

The above is the detailed content of What does a php variable name consist of?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!