Home  >  Article  >  Backend Development  >  What symbol starts with when declaring variables in php?

What symbol starts with when declaring variables in php?

下次还敢
下次还敢Original
2024-04-29 09:45:23540browse

Declaring variables in PHP starts with a dollar sign ($). Other considerations include: variables are case-sensitive, can only contain letters, numbers, and underscores, cannot start with a number or contain spaces/special characters, and cannot use reserved words as variable names.

What symbol starts with when declaring variables in php?

Symbols for declaring variables in PHP

In PHP, variable names start with a dollar sign ($).

Example:

<code class="php">$name = "John";
$age = 30;</code>

Other notes:

  • Variable names are case-sensitive, i.e. $name and $NAME is a different variable.
  • Variable names can only contain letters, numbers, and underscores (_).
  • Variable names cannot start with numbers.
  • Variable names cannot contain spaces or special characters.
  • Reserved words (such as true, false, null, etc.) cannot be used as variable names.

The above is the detailed content of What symbol starts with when declaring variables in php?. 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