本教程操作环境: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()函数用于反转字符串。


![晴川云Minecraft Wiki教程:初始资源[ ],晴川云](https://baike.qcidc.com/wp-content/uploads/2025/09/20250919082406636-u_29926827_77771307fm_253fmt_autoapp_138f_JPEG.jpeg)







暂无评论内容