What symbol must a variable start with in php?

下次还敢
Release: 2024-04-29 09:42:12
Original
398 people have browsed it

PHP variable names must start with the following symbols: 1. Dollar sign ($) 2. Underscore (_) 3. Backslash (); but cannot start with numbers, punctuation marks, or reserved words.

What symbol must a variable start with in php?

Symbols at the beginning of PHP variables

In PHP, variable names must start with the following symbols:

  • Dollar sign ($): This is the most commonly used variable symbol in PHP. For example: $variable_name.

Other valid symbols:

  • Underscore (_): can be used as the first character of a variable name , but not common. For example: _variable_name.
  • Backslash (\): Can only be used in a namespace to reference variables with global scope. For example: \\global_variable.

Invalid symbols:

  • Numbers: Variable names cannot begin with a number. For example: 1variable_name.
  • Punctuation: Variable names cannot begin with punctuation. For example: .variable_name.
  • Reserved words: Variable names cannot use PHP reserved words. For example: echo, return.

The above is the detailed content of What symbol must a variable start with in php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
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!