PHP View the current variable type method _php instance

Source: Internet
Author: User

The following PHP to view the current variable type background, procedures and solutions are written out for everyone, as follows:

Solve the background

Toss process one:

Resolved the JSON Json_decode in PHP does not work without any output

Period, you need to understand one:

Copy Code code as follows:

Php:curl_exec–manual

Curl_exec returns the type of variable $respjson and is not a string type.

Toss process two:

1. Search:

Copy Code code as follows:

PHP Check Variable type

Reference:

Php:gettype–manual

Php:is_string–manual

Php:is_int–manual

So go and try:

Copy Code code 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);

Results:

There is no output ...

2. Try:

Copy Code code as follows:

Echo GetType ($respJson);
echo is_string ($respJson);

Results:

Copy Code code as follows:

Output: String1

That proves that the type of the variable here is indeed string.

Summarize

The type of variable obtained in PHP is GetType ($var);

Individual judgments are of some type and can be used:

Copy Code code as follows:

Is_int
Is_string

Wait a minute.

The above is for PHP to view the current variable types of methods, I hope you like.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.