Home  >  Article  >  Backend Development  >  PHP background, process and solution for viewing current variable type

PHP background, process and solution for viewing current variable type

墨辰丷
墨辰丷Original
2018-06-07 17:46:572203browse

This article mainly introduces the background, process and solution of checking the current variable type in PHP. Interested friends can refer to it. I hope it will be helpful to everyone.

Solution background

Tossing process one:

Solution The json_decode of json in PHP does not work. During any output

, you need to understand one thing:

The code is as follows:

PHP: curl_exec – Manual

What is the type of the variable $respJson returned by curl_exec? 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 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:

Copy code The code is as follows:


echo gettype($ respJson);
echo is_string($respJson);


Result:

The code is as follows:

输出:string1

Then prove that here The type of the variable 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
等等。

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

PHP Mysql Ajax method to implement Taobao customer service Aliwangwang chat function (front page)

php Detailed explanation of downloading remote large file instance

php Detailed graphic explanation of generating encrypted public key and encrypted private key

The above is the detailed content of PHP background, process and solution for viewing current variable type. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn