这样可以吗?或者可以更加优化吗
来源:1-6 编程练习
慕桂英6468770
2017-10-23 20:55:11
<?php
$name='stefen';
$phone='10795856';
$point='If you shed tears when you miss the sun,then you would miss the stars';
$x=strlen($name);
$y=strlen($phone);
$z=strlen($point);
echo $x+$y+$z;
echo "<hr/>";
echo strlen($name.$phone.$point);
?>
1回答
您好,您的方式正确。但是代码可以更简化一些。
可以直接将内容连接为一个变量,直接计算一个变量的长度。
$name='stefen'; $phone='10795856'; $point='If you shed tears when you miss the sun,then you would miss the stars'; $subject = $name.$phone.$point;//连接字符串 var_dump(strlen($subject));//计算长度
如果解决了您的问题,请采纳,祝学习愉快!
相似问题