PHP background, process and solution for viewing current variable type

墨辰丷
Release: 2023-03-30 15:52:01
Original
2316 people have browsed it

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
Copy after login

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
Copy after login

Reference:

PHP: gettype – Manual
PHP: is_string – Manual
PHP: is_int – Manual
Copy after login

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);
Copy after login


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
Copy after login

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
等等。
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!