Get the App
SLTechnology News&Howtos  ›  Development  › 

Which is the permanent conversion function of the php data type

Shulou Source: shulou.com Published: 2022-06-02 06:58:31 10月04日 Update

This article mainly explains "which is the permanent conversion function of php data type". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn which is the permanent conversion function of the php data type.

The persistent conversion function of the php data type is "settype ()". The settype () function is used to set the type of the variable, which permanently changes the data type of the variable itself; the syntax "settype ($var,$type)" and the parameter "$type" specify the target data type to convert.

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

In PHP, there are many functions that implement data type conversion: intval (), floatval (), boolval (), strval (), settype ().

However, the intval (), floatval (), boolval (), strval () functions do not change the type of the converted variable itself, but by assigning the new type of data to the new variable, the type and value of the original variable remain unchanged. It is not possible to convert permanently.

Settype () can permanently change the data type of the variable itself, syntax:

Settype ($var,$type)

Sets the type of the variable $var to $type.

The possible values of $type are:

"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)

Example:

At this point, I believe you have a deeper understanding of "which is the permanent conversion function of the php data type". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Type data function permanent variable content grammar learning practical deeper interest parameter multiple practical practical easy to operate tutorials methods methods more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Linux Redmi MariaDB Shulou Tech Info