Php 用list()指定一个变量

Php 用list()指定一个变量,php,Php,当我们必须只返回一个由sscanf/fscanf解析的值时,我们应该分配一个变量列表还是使用可选的分配值 例如 或 这些表达式的执行速度有什么不同吗?只需使用如下脚本对两种方法进行基准测试: <?php function micro_time() { $temp = explode(" ", microtime()); return bcadd($temp[0], $temp[1], 6); } $time_start = micro_time(); for ($i=0

当我们必须只返回一个由sscanf/fscanf解析的值时,我们应该分配一个变量列表还是使用可选的分配值

例如


这些表达式的执行速度有什么不同吗?

只需使用如下脚本对两种方法进行基准测试:

<?php
function micro_time() {
    $temp = explode(" ", microtime());
    return bcadd($temp[0], $temp[1], 6);
}

$time_start = micro_time();

for ($i=0; $i<100; $i++) {

    // the code you want to benchmark

}

$time_stop = micro_time();

$time_overall = bcsub($time_stop, $time_start, 6);
echo "Execution time - $time_overall Seconds";
?>

fscanf($handle, "%d\n", $number)
<?php
function micro_time() {
    $temp = explode(" ", microtime());
    return bcadd($temp[0], $temp[1], 6);
}

$time_start = micro_time();

for ($i=0; $i<100; $i++) {

    // the code you want to benchmark

}

$time_stop = micro_time();

$time_overall = bcsub($time_stop, $time_start, 6);
echo "Execution time - $time_overall Seconds";
?>