php反转整数的方法:1、使用strval()函数,将指定整数转为字符串类型,语法“strval(整数)”;2、使用strrev()函数反转整数字符串即可,语法“strrev(整数字符串)”。
本教程操作环境:windows7系统、PHP7.1版、DELL G3电脑
php怎么反转一个整数
在php中,想要反转一个整数,可以借助strrev()函数:
先将指定整数转为字符串类型
然后使用strrev()函数反转整数字符串即可
实现代码:
<?php
header("Content-type:text/html;charset=utf-8");
function reverse($num) {
$str=strval($num);
echo strrev($str)."<br>";
}
reverse(123);
reverse(234);
reverse(23455);
reverse(34235);
reverse(43233);
?>
说明:
strval()函数用于获取变量的字符串值。
strrev()函数用于反转字符串。