Get the App
SLTechnology News&Howtos  ›  Development  › 

How php converts variables to array types

Shulou Source: shulou.com Published: 2022-06-01 18:39:21 09月15日 Update

The knowledge of this article "php how to convert variables into array types" is not understood by most people, so the editor summarizes the following contents, detailed contents, clear steps, and certain reference value. I hope you can get something after reading this article. Let's take a look at this "php how to convert variables into array types" article.

The method of converting to an array type: 1, add the target type "(array)" enclosed in parentheses before the numeric variable to be converted, and the syntax "(array) convert variable"; 2, use the settype () function, and the syntax "settype (conversion variable,"array").

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Php converts variables to array types

Method 1: add the target type "(array)" enclosed in parentheses before the numeric variable to be converted

(array): converting to an array type

Example:

Method 2: use the settype () function

The settype ($var, $type) function sets the variable $var to a value that can be set by the specified type $type,$type:

"boolean" (or "bool", starting with PHP 4.2.0)

"integer" (or "int", starting with PHP 4.2.0)

"float" (available only after PHP 4.2.0, "double" used in older versions is now disabled)

"string"

"array"

"object"

"null" (since PHP 4.2.0)

Note: the settype () function changes the type of the variable itself.

Example:

The above is about the content of this article on "how php converts variables to array types". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Types variables arrays content functions methods parentheses values articles goals knowledge examples articles grammar usefulness value most of them that is tutorials more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Apple MySQL Shulou Tech Info macOS