PHP.nl

eio_rename

eio_rename

Change the name or location of a file

resource **eio_rename** string $path string $new_path int $pri callable $callback mixed $data
renames or moves a file to new location.

eio_rename

pathSource path

new_pathTarget path

pri``callback``data Arbitrary variable passed to . callback

returns request resource on success,return.falseforfailure.

eio_rename

Voorbeeld: example

<?php
$filename = dirname(__FILE__)."/eio-temp-file.dat";
touch($filename);
$new_filename = dirname(__FILE__)."/eio-temp-file-new.dat";

function my_rename_cb($data, $result) {
    global $filename, $new_filename;

    if ($result == 0 && !file_exists($filename) && file_exists($new_filename)) {
        @unlink($new_filename);
        echo "eio_rename_ok";
    } else {
        @unlink($filename);
    }
}

eio_rename($filename, $new_filename, EIO_PRI_DEFAULT, "my_rename_cb", $filename);
eio_event_loop();
?>
eio_rename_ok