In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "summary of relevant knowledge points of PHP variables". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "summary of relevant knowledge points of PHP variables".
In PHP, a variable is a $+ variable name. Variable names follow the naming rules of identifiers. They can start with letters and underscores, and legal variable names can be composed of numbers, underscores and letters.
Variable declaration
All variables should be declared before use, and it is best to be annotated, although declared variables may not be displayed in PHP. After you declare a variable, you can assign a value to it; there are two types of variable assignment: value assignment and reference assignment.
Scope of variables
Variables can be declared anywhere in the PHP script, but the scope varies depending on the location.
Local variable
In general, local variables are declared in the function, that is, it can only be referenced in the function, and the variable and its value are destroyed when the function exits. If you use this variable outside the function, PHP treats it as another variable that has nothing to do with the variable in the function.
Function parameter
Function parameters can be passed in two ways: by value and by reference; if they are passed by value, the scope of the parameters is limited to the function, and the parameters are destroyed after the function exits. However, by reference, the scope of the parameter is not only within the function.
Global variable
You can access global variables anywhere in the script, but you need to use the keyword global to explicitly declare when you want to modify global variables in a function.
Global variables can also be declared through the $GLOBAL array
Global variables must be used carefully, because too much use can easily lead to code confusion.
Static variable
Static variables differ from function parameters in that static variables are declared with the static keyword, so that static variables are not destroyed after the function exits, and this value is retained to use this value when the function is called again.
PHP predefined variables
There are a number of predefined variables in PHP that can be accessed wherever the script is executed, mainly providing a great deal of information about the environment.
/ / print out the predefined variable information of $_ SERVER foreach ($_ SERVER as $var= > $value) {echo "$var= > $value";}
First take a look at the contents of the string dynamically inserted into the variable when PHP is in progress. The details are as follows:
In PHP, strings are usually enclosed in double or single quotation marks.
Echo "Zhang San, Li Si, Wang Wu asked Zhao Liu to go for a drink."
If we want to dynamically insert data into a string, we will not only use. Number concatenation, you can also identify the dynamic part of the string by using {}.
Through the above code, we find that:
It is invalid to insert a variable directly in double quotation marks
Characters can be escaped by backslash () in double quotes, but single quotes in double quotes do not need to be escaped by backslash
In single quotation marks, except that you can escape single quotation marks, it is invalid for other characters to escape backslash.
You can dynamically insert variables in double-quote strings through {}.
Thank you for your reading, the above is the content of the "summary of relevant knowledge points of PHP variables". After the study of this article, I believe you have a deeper understanding of the summary of relevant knowledge points of PHP variables, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.