Home  >  Article  >  Backend Development  >  What is the correct way to define variables in php

What is the correct way to define variables in php

藏色散人
藏色散人Original
2019-10-28 17:17:3310306browse

What is the correct way to define variables in php

#What is the correct way to define variables in php?

For example, a basic test question about PHP variables is:

The following statement of PHP variables is correct ( )

A, $name="dadfa";

B、int i;

C、var int $a;

D、string $name="sunch";

Answer: A

PHP variable rules:

Variables start with a $ symbol, followed by the name of the variable

Variable names must start with a letter or an underscore

Variable names cannot begin with a number

Variable names can only contain alphanumeric characters and underscores (A-z, 0-9, and _)

Variable names are case-sensitive ($y and $Y are two different variables)

Note: PHP variable names are case-sensitive! If the value you assign to a variable is text, surround the value in quotes.

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of What is the correct way to define 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