Home >Backend Development >PHP Problem >How to convert integer to string in php

How to convert integer to string in php

王林
王林Original
2020-08-01 14:13:104780browse

php method to convert integers to strings: You can use the conversion function strval() to achieve this. The strval() function is used to obtain the string value of a variable. The function syntax is: [string strval (mixed $var)], where $var can be any scalar type, but cannot be an array or object.

How to convert integer to string in php

You can use specific type conversion functions, such as intval(), floatval(), strval().

(Recommended tutorial: php graphic tutorial)

strval() function is used to obtain the string value of a variable.

Syntax:

string strval (mixed $var)

Parameters:

$var: Can be any scalar type, but cannot be an array or object.

(Video tutorial recommendation: php video tutorial)

Code implementation:

<?php
$int_str= 123;
var_dump($int_str);
$str = strval(123);
var_dump($str);
?>

Output result:

int(123)
string(3) "123"

The above is the detailed content of How to convert integer to string in php. 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