This article mainly introduces the method of checking the current variable type in PHP. Friends who need it can refer to it.
The following is the background, process and solution of checking the current variable type in PHP. , the details are as follows:
Solution background
Tossing process one:
The json in PHP has been solved json_decode is not working and there is no output. During this period, you need to understand one thing:
PHP: curl_exec – Manual
curl_exec What is the type of the variable $respJson returned, and whether it is a string type.
Tossing process two:
1. Search:
php check variable type
PHP: gettype – Manual
PHP: is_string – Manual
PHP: is_int – Manual
So try it:
$respJson = $crifanLib->getUrlRespHtml($getTokenUrl); $crifanLib->logWrite("respJson=%s", $respJson); echo gettype($respJson); echo is_string($respJson); echo "before decodedJsonObj"; $decodedJsonObj = json_decode($respJson);
Still no output. . .
2. Try:
echo gettype($respJson); echo is_string($respJson);
输出:string1
This proves that the type of the variable here is indeed It's a string.
Summary
The variable type obtained in PHP is gettype($var);
To determine whether it is a certain type alone, you can use:is_int is_string
Analysis of the implementation principles of scheduled tasks in PHP
Use PHP's scope analysis Operator(::)
The above is the detailed content of How to view the current variable type using PHP. For more information, please follow other related articles on the PHP Chinese website!