This article mainly introduces how to view the current variable type in PHP, you can refer to the following section to view the background, process, and solution of the current variable type in PHP. The details are as follows:
Background
Tossing process 1:
Solved json json_decode in PHP and no output
During this period, you need to understand one:
The Code is as follows:
PHP: curl_exec-Manual
The variable $ respJson returned by curl_exec is of the string type.
Tossing process 2:
1. Search:
The Code is as follows:
Php check variable type
Refer:
PHP: gettype-Manual
PHP: is_string-Manual
PHP: is_int-Manual
So try:
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:
Output: string1
It proves that the type of the variable here is indeed string.
Summary
The variable type obtained in PHP is gettype ($ var );
It is determined to be of a specific type. You can use:
The Code is as follows:
Is_int
Is_string
And so on.
The above is the method for viewing the current variable type in PHP. I hope you will like it.