Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the setting method of variables in php

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what is the method of setting variables in php". In daily operation, I believe that many people have doubts about the method of setting variables in php. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts of "what is the method of setting variables in php?" Next, please follow the editor to study!

Php variable setting method: 1, create a PHP sample file; 2, through the "$symbol + variable name" way to set the variable, the code such as "$txt=" Hello world! ";".

This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer

The setting method of variables in php

PHP variable

Variables 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.

At this point, the study on "what is the method of setting variables in php" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report