When the variable is an empty string and a Boolean value of false and the value 0 o'clock, isset all returns True, directly judging all return false:
$empty='';echo (isset($empty)?'1':0);//1echo'';echo ($empty?'1':0);//0
$empty=false;echo
At this point, the is_scalar built-in function comes in handy.
Is_scalar--detects if a variable is a scalar
Scalar variables are variables that contain an integer, float, String, or Boolean, while array, object, and resource are not scalars.
There are various types of variables in PHP, different types have different ways of judging, here is a summary of some of the types of variables in PHP judgment.
First, GetType ()GetType returns the following values based on the parameter
For example
$contents = curl_exec ($ch); Preg_match_all ("/(. *) /", $contents, $arr), for ($i =0; $i ';}}
I don't want to print $arr now, but put it in a string variable
Reply to discussion (solution)
$txt = "; for ($i =0; $i ';
Php writes a piece of code to change the variable value. If 3rd variables are not used, the values of $ a and $ B are exchanged, and the initial values of $ a and $ B are set ., This Baidu is a lot .... These two numbers must be integer numbers ...,
In the same class, how do you invoke a variable value from function B in function a?
Reply to discussion (solution)
No way!Please read carefully the description of the scope of variables in the manual
It can be set as a global
How do you get the value of the name in PHP for the variable?
$result = $row [' result '];
$pid = $row [' pid '];
if ($result = = ' compliant ')
{
echo "
Meet";
echo "
does not meet";
echo "
does not involve";
}
if ($result = = ' Not compliant ')
$ _ SERVER ['php _ SELF '] function usage # File Name of the script being executed, which is related to document root.
$ _ SERVER ['argv'] function usage # parameters passed to the script.
$ _ SERVER ['argc '] function usage # contains the number
Http_get_vars is saved with a Get variable since PHP4.1.0, and the get variables are mainly derived from the following methods
For example, a URL that uses the method of a form to obtain information about the server for instance, a get way. So all
Take a look at the following example:
Copy Code code as follows:
function Test ()
{
$w 3sky = 0;
echo $w 3sky;
$w 3sky++;
}
?>
This function sets the value of $w 3sky to 0 and outputs "0" each time it is invoked.
The following three implementations are used to introduce the specified characters of variables in php Regular Expression replacement. For more information, see.
Three methods.
1.
The Code is as follows:
Copy code
$ Str =
Php programmers are familiar with the term process. Php engineers generally do not have a deep understanding of object-oriented, so they need to call external variables in methods in a large process, therefore, there will be many opportunities for
The scope of the global variable is defined at the end of the source file, the storage period is defined and the memory is allocated, and the program releases memory after exiting;
Local variable scope is local, storage period is defined after
In PHP, the $ _ SERVER variable sorts out the current url :. $ _ SERVER [HTTP_HOST]. $ _ SERVER [PHP_SELF]; $ _ SERVER variable summary $ _ SERVER [QUERY_STRING] query string. $ _ SERVER [DOCUMENT_ROOT] $ _ SERVER variable sorting in PHP currently
In PHP because variables do not need to be defined in advance, we have a lot of time for the PHP variable type is cheek paste, but PHP gives us the GetType () function to get the variable type, he can judge all the variable types in PHP.
Detecting
The following code is saved as test.php
'; $_session[' test '] = $_server[' Path_info '];var_dump ($_session[' test ');? >
Test this code locally to access the URL http://localhost/test.php/aThe value of $_server[' Path_info '] is '/a ', the
The difference between isset (variable) and direct judgment variables in PHP
When the variable is an empty string and a Boolean value of false and the value 0 o'clock, isset all returns True, directly judging all return false:
$empty='';echo (isset(
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.