Tag: 内存的

内存消耗迭代脚本

我有用PHP编写的脚本和用Javascript编写的相同的脚本。 它迭代一百万次,每次将一个string剥离到一个数组中,并将第一个数组项赋给一个新的variables。 PHP是: class First { public function Iterate() { $count = 1000000; $test_string = ''; $test_array = ''; $first_word = ''; for($i=1; $i <= $count; $i++){ $test_string = 'This is a test string'; //could use explode but no explode in js $test_array = split(" ", $test_string); $first_word = $test_array[0]; } } } $first = […]