码迷,mamicode.com
首页 > Web开发 > 详细

4-5 PHP-避免在循环内做运算... for()括号内做运算

时间:2017-03-07 08:56:27      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:hello   span   好的   性能   php   something   ...   括号   div   

<?php

//性能差的
$str=‘hello world‘;
for ($i=0;$i<strlen($str);$i++){
    //do something
}


//性能好的
$str=‘hello world‘;
$len=strlen($str);
for ($i=0;$i<$len;$i++){
    //do something
}

 

4-5 PHP-避免在循环内做运算... for()括号内做运算

标签:hello   span   好的   性能   php   something   ...   括号   div   

原文地址:http://www.cnblogs.com/jiaochengli/p/6512823.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!