It rewinds the position of a file pointer
Example
<?php
$fp = fopen(‘test.txt’, ‘r+’);
fwrite($fp, ‘PHPCodez’);
rewind($fp);
fwrite($fp, ‘phpcodez’);
fclose($fp);
?>
It rewinds the position of a file pointer
Example
<?php
$fp = fopen(‘test.txt’, ‘r+’);
fwrite($fp, ‘PHPCodez’);
rewind($fp);
fwrite($fp, ‘phpcodez’);
fclose($fp);
?>
It renames a file or directory
Example
<?php
rename(“test.txt”, “new-test.txt”);
?>
It returns realpath cache size
Example
<?php
echo “<pre>”;
print_r(realpath_cache_size());
?>
Output
344
It returns realpath cache entries
Example
<?php
echo “<pre>”;
print_r(realpath_cache_get());
?>
It returns the target of a symbolic link
Example
<?php
echo readlink(‘test’);
?>
It outputs a file
Example
<?php
$file = ‘test.txt’;
if (file_exists($file)) {
header(‘Content-Description: File Transfer’);
header(‘Content-Type: application/octet-stream’);
header(‘Content-Disposition: attachment; filename=’.basename($file));
header(‘Content-Transfer-Encoding: binary’);
header(‘Expires: 0’);
header(‘Cache-Control: must-revalidate’);
header(‘Pragma: public’);
header(‘Content-Length: ‘ . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
It opens process file pointer
Example
<?php
$pfp = popen(‘/bin/ls’, ‘r’);
pclose($pfp);
?>
It closes process file pointer
Example
<?php
$pfp = popen(‘/bin/ls’, ‘r’);
pclose($pfp);
?>
It returns information about a file path
Example
<?php
echo “<pre>”;
print_r(pathinfo(“test.ini”));
?>
Output
Array
(
[dirname] => .
[basename] => test.ini
[extension] => ini
[filename] => test
)
It parse a configuration string
Example
<?php
echo “<pre>”;
print_r(parse_ini_string(file_get_contents(“test.ini”)));
?>
Output
Array
(
[me] => phpcodez
[first] => http://www.phpcodez.com
)
“test.ini” file content
[names]
me = phpcodez
[urls]
first = “http://www.phpcodez.com”