PHP to view the current variable type, php to view the current variable

Source: Internet
Author: User

PHP to view the current variable type, php to view the current variable

The following describes the background, process, and solution for PHP to view the current variable type. 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:

Copy codeThe 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:

Copy codeThe Code is as follows:
Php check variable type

Refer:

PHP: gettype-Manual

PHP: is_string-Manual

PHP: is_int-Manual

So try:

Copy codeThe 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 codeThe Code is as follows:
Echo gettype ($ respJson );
Echo is_string ($ respJson );

Result:

Copy codeThe 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:

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

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.