Home  >  Article  >  Backend Development  >  How to convert php string to number

How to convert php string to number

藏色散人
藏色散人Original
2020-09-28 09:13:574878browse

How to convert php strings into numbers: First create a PHP sample file; then convert the strings into integers through the intval function; and finally output the converted numbers through echo.

How to convert php string to number

Recommended: "PHP Video Tutorial"

Getting the content submitted by the form and getting the value of the query string When doing so, it is often necessary to convert the obtained content. Conversion between strings and numbers in PHP can be achieved through the function intval() and the function strval().

Converting a string into an integer can be achieved through the function intval().

Syntax:

int intval ( mixed var [, int base])

Function:

intval() function returns the integer value of variable var by using a specific base conversion (default is decimal).

Converting numbers to strings can be achieved through the function strval().

Syntax:

string strval ( mixed var)

Function:

strval() function is used to return the string value corresponding to the variable var.

In PHP, you can get the type of any variable through the function gettype().

Syntax:

string gettype( mixed var)

Function:

The gettype() function is used to return the type of variable var.

The above is the detailed content of How to convert php string to number. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn