php 代码如何使用,PHP如何使用strval()函数?用法和代码示例
strval()函數(shù)是PHP中的內(nèi)置函數(shù), 用于將任何標(biāo)量值(字符串, 整數(shù)或雙精度)轉(zhuǎn)換為字符串。咱們不能在數(shù)組或?qū)ο笊鲜褂胹trval(), 若是應(yīng)用了該函數(shù), 則此函數(shù)僅返回要轉(zhuǎn)換的值的類型名稱。php
語法:html
strval( $variable )
參數(shù):此函數(shù)接受單個參數(shù)$變量。此參數(shù)表示咱們要轉(zhuǎn)換為字符串的值數(shù)組
返回值:此函數(shù)返回一個字符串。該字符串是經(jīng)過類型轉(zhuǎn)換做為參數(shù)傳遞給它的變量的值生成的。瀏覽器
下面的程序說明了strval()函數(shù)。函數(shù)
程序1:.net
$var_name = 32.360;
// prints the value of above variable
// as a string
echo strval ( $var_name );
?>
輸出以下:code
32.36
程序2:htm
class lsbin
{
public function __toString()
{
// returns the class name
return __CLASS__ ;
}
}
// prints the name of above class as
// a string
echo strval ( new lsbin);
?>
輸出以下:對象
lsbin
程序3:開發(fā)
// Program to illustrate the strval() function
// when an array is passed as parameter
// Input array
$arr = array (1, 2, 3, 4, 5);
// This will print only the type of value
// being converted i.e. 'Array'
echo strval ( $arr );
?>
PHP相關(guān)內(nèi)容推薦:
總結(jié)
以上是生活随笔為你收集整理的php 代码如何使用,PHP如何使用strval()函数?用法和代码示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle10g优化器默认,Oracl
- 下一篇: 王者荣耀mvp最高评分是多少