The following is the background, process and solution for viewing the current variable type in PHP. The details are as follows:
Solution background
Tossing process one:
The json_decode of json in PHP has been solved. There is no output during the work
, you need to understand one:
The code is as follows:
PHP: curl_exec – Manual
curl_exec returns What is the type of the variable $respJson? Is it the string type?
Tossing process two:
1. Search:
The code is as follows:
php check variable type
Reference:
PHP: gettype – Manual
PHP: is_string – Manual
PHP: is_int – Manual
So go try it:
The code is as follows:
$respJson = $crifanLib->getUrlRespHtml($getTokenUrl); $crifanLib->logWrite("respJson=%s", $respJson); echo gettype($respJson); echo is_string($respJson); echo "before decodedJsonObj"; $decodedJsonObj = json_decode($respJson);
Result :
Still no output. . .
2. Try:
The code is as follows:
echo gettype($respJson); echo is_string($respJson);
Result:
The code is as follows:
输出:string1
That proves that the type of the variable here is indeed string.
Summary
The variable type obtained in PHP is gettype($var);
To determine whether it is a certain type alone, you can use:
The code is as follows:
is_int is_string
and so on.
The above is the detailed content of Detailed explanation of how to view the type instance of the current variable in PHP. For more information, please follow other related articles on the PHP Chinese website!