declare() 函数怎么理解 我看教程运行不出来 弹出错误
不知道怎么用这函数 请高人指教下 <?php
// A function that records the time when it is called
function profile ($dump = FALSE)
{
    static $profile;    // Return the times stored in profile, then erase it
    if ($dump) {
        $temp = $profile;
        unset ($profile);
        return ($temp);
    }    $profile[] = microtime ();
}// Set up a tick handler
register_tick_function("profile");// Initialize the function before the declare block
profile ();// Run a block of code, throw a tick every 2nd statement
declare (ticks=2) {
    for ($x = 1; $x < 50; ++$x) {
        echo similar_text (md5($x), md5($x*$x)), "<br />;";
    }
}// Display the data stored in the profiler
print_r (profile (TRUE));
?>

解决方案 »

  1.   

    <?phpfunction profile($dump = FALSE)
    {    echo "okok <br />";
    }
    register_tick_function("profile");
    declare(ticks=5) {
        for ($x = 1; $x < 50; ++$x) {
            echo "$x <br />";
        }
    }?> 
      

  2.   




    okok 


    okok 



    okok 

    10 
    okok 
    11 
    12 
    13 
    okok 
    14 
    15 
    okok 
    16 
    17 
    18 
    okok 
    19 
    20 
    okok 
    21 
    22 
    23 
    okok 
    24 
    25 
    okok 
    26 
    27 
    28 
    okok 
    29 
    30 
    okok 
    31 
    32 
    33 
    okok 
    34 
    35 
    okok 
    36 
    37 
    38 
    okok 
    39 
    40 
    okok 
    41 
    42 
    43 
    okok 
    44 
    45 
    okok 
    46 
    47 
    48 
    okok 
    49 
    okok