ext-uv/examples/fs.php

31 lines
537 B
PHP
Raw Normal View History

2012-06-22 01:20:22 +02:00
<?php
function r($rs,$data)
{
global $buf;
global $x;
$buf .= $data;
if ($rs != 0) {
2012-06-22 16:01:32 +02:00
if ($rs < 0) {
throw new Exception("error");
}
2012-06-22 01:20:22 +02:00
echo "moe";
uv_fs_read(uv_default_loop(),$x,"r");
} else {
var_dump($buf);
2012-06-22 05:13:11 +02:00
uv_fs_close(uv_default_loop(), $x,function(){
echo "# closed\n";
});
2012-06-22 01:20:22 +02:00
}
}
2012-06-22 17:53:58 +02:00
uv_fs_open(uv_default_loop(),__FILE__, 0, 0, function($r){
2012-06-22 01:20:22 +02:00
global $x;
$x = $r;
uv_fs_read(uv_default_loop(),$r,"r");
});
uv_run();