Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the variable in php

Shulou Source: shulou.com Published: 2022-06-02 14:39:58 09月17日 Update

This article introduces the relevant knowledge of "what are variables in php". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Variables in php are "containers" for storing information, and similar to algebra, PHP variables can be assigned a value (xchang5) or an expression (z=x+y); variables can be short names (such as x and y) or more descriptive names (such as age, carname, totalvolume).

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

What does a variable mean in php?

Variables in php are containers for storing information.

Similar to algebra, a PHP variable can be assigned a value (XForm5) or an expression (z=x+y).

Variables can be short names, such as x and y, or more descriptive names, such as age, carname, totalvolume.

PHP variable rules:

The variable begins with the $symbol, followed by the name of the variable

Variable names must start with a letter or an underscore character

Variable names can only contain letters, numbers, and underscores (Amurz, 0-9, and _)

Variable names cannot contain spaces

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

Both lamp PHP statements and PHP variables are case-sensitive.

Create (declare) PHP variable

PHP does not have a command to declare variables.

The variable is created the first time you assign it:

Example

In the above statement execution, the variable txt will hold the value Hello worldview, and the variable x will hold the value 5.

Note: when you assign a text value to a variable, put quotation marks around the text value.

That's all for "what are variables in php?" Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Variables names underscores algebra information content size letters containers descriptive text more knowledge expressions statements storage different practical learned next Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Docker Microsoft Xiaomi macOS