PHP View method Rollup for current variable types

Source: Internet
Author: User
PHP supports 8 basic types of data.

Four types of scalar:
Boolean (Boolean): This is the simplest type, with only two values, which can be true/true or false/false, not case-sensitive. For more information, see: Php Boolean Type (Boolean)
Integer (integer): It has a valid range of 32-bit operating systems:-2 147 483 648~+2 147 483 647. Integer values can be expressed in decimal, hexadecimal, or octal, preceded by an optional symbol (-or +). Octal indicates that the number must be preceded by 0 (0), and hexadecimal indicates that the number must be preceded by 0x. For more information, see: PHP Integer data (integer)
Float (floating point, also called double): the valid range in a 32-bit operating system is: 1.7e-308~1.7e+308. For more information, see: PHP Floating-point type (float)
String: A character variable differs from another programming language in that it has characters and strings, and in PHP, a character variable is used uniformly to define a character or string. For more information, see: PHP String type

Two kinds of composite types:
Arrays: Array variables are a special type of variable that will be described in detail in subsequent chapters.
Object: Objects are also a special type of data. To create an object variable, use the New keyword. For more information, see: PHP Object Type

Finally, there are two special types:
Resource (Resource): A source is a special variable that holds a reference to an external resource. Resources are created and used through specialized functions. For more information, see: PHP Resource Type (Resource)
Null (NULL): Indicates that a variable has no value. The only possible value for a null type is NULL.

This article mainly introduces PHP to view the current variable types of methods, the need for friends can refer to the following

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

Resolving the background

Process one:

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

Period, need to understand a:

Php:curl_exe

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

Process two:

1. Search:

PHP Check Variable type

Reference:

Php:gettype–manual

Php:is_string–manual

Php:is_int–manual

So try it out:

$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:

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

Results:

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:

Is_intis_string

Wait a minute.

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.