PHP View the current variable type method _php instance

Source: Internet
Author: User
Below the PHP view of the current variable type background, process and solutions are written to everyone, as follows:

Resolving the background

Toss process one:

The Json_decode of JSON in PHP has not worked without any output

Period, need to understand a:

Copy the Code code as follows:
Php:curl_exec–manual

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

Toss process two:

1. Search:

Copy the Code code as follows:
PHP Check Variable type

Reference:

Php:gettype–manual

Php:is_string–manual

Php:is_int–manual

So try it out:

Copy the 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 still no output ...

2. Try:

Copy the Code code as follows:
Echo GetType ($respJson);
echo is_string ($respJson);

Results:

Copy the Code code as follows:
Output: String1

It proves that the type of the variable here is indeed a string.

Summarize

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

Individual judgments are of a certain type, which can be used:

Copy the 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.

  • Related Article

    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.