Home  >  Article  >  Backend Development  >  How to convert variable into string in php

How to convert variable into string in php

王林
王林Original
2020-09-03 14:24:274449browse

php method to convert variables into strings: use the built-in function strval(), the syntax is "strval (var)", where var can be any scalar type; the strval() function can get the string of the variable value and returned, but cannot be used for arrays or objects.

How to convert variable into string in php

There is a built-in function strval() in php, which is used to get the string value of a variable and return it.

(Recommended tutorial: php video tutorial)

Function syntax:

string strval ( mixed $var )

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

Code example:

(Related recommendations: php training)

Output result:

string(3) "123"

The above is the detailed content of How to convert variable into 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