Home  >  Article  >  Backend Development  >  How to convert int to string type in php

How to convert int to string type in php

王林
王林Original
2020-09-01 13:20:0711386browse

php method to convert int to string type: You can use the built-in function strval() to convert, the syntax is "strval (int type value)"; the strval() function can get the string value of the specified variable . It should be noted that the strval() function cannot be used for arrays or objects.

How to convert int to string type in php

php provides us with a built-in function strval(), which can get the string value of a variable.

(Recommended tutorial: php video tutorial)

Syntax:

string strval ( mixed $var )

Return value:

The function returns the string value of var .

Note: var can be any scalar type. You cannot use strval() with arrays or objects.

(Related recommendations: php training)

Example:

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

Result:

string(3) "123"

The above is the detailed content of How to convert int to string type 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