How to convert php string to number

藏色散人
Release: 2023-03-06 06:32:01
Original
4799 people have browsed it

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])
Copy after login

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)
Copy after login

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)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!