It returns inode change time of file
Example
<?php
echo date(“D m Y h i s”,filectime(“test.txt”));
?>
Output
Fri 05 2007 03 15 53
It returns inode change time of file
Example
<?php
echo date(“D m Y h i s”,filectime(“test.txt”));
?>
Output
Fri 05 2007 03 15 53
It returns last access time of file
Example
<?php
echo date(“D m Y”,fileatime(“test.txt”));
?>
Output
Fri 05 2007
It reads entire file into an array
Example
<?php
echo “<pre>”;
print_r(file(“test.txt”));
?>
Output
Array
(
[0] => phpcodez
)
It writes a string to a file
Example
<?php
file_put_contents(“test.txt”,”phpcodez”);
?>
It reads entire file
Example
<?php
echo file_get_contents(“test.txt”);
?>
It checks whether a file or directory exists
Example
<?php
echo file_exists(“test.txt”)?”Yes”:”No”;
?>
It returns line from file pointer and strip HTML tags
Example
<?php
$fp = @fopen(“test.txt”, “r”);
if ($fp) {
while (($content = fgetss($fp, 4096)) !== false) {
echo $content;
}
fclose($fp);
}
?>
It returns line from file pointer
Example
<?php
$fp = @fopen(“test.txt”, “r”);
if ($fp) {
while (($content = fgets($fp, 4096)) !== false) {
echo $content;
}
fclose($fp);
}
?>
It returns line from file pointer and parse for CSV fields
Example
<?php
$filename = “test.csv”;
echo “<table border=’1′>”;
if (($handle = fopen($filename, “r”)) !== FALSE) {
while (($data = fgetcsv($handle, 1000, “,”)) !== FALSE){ ?>
<tr><?php foreach($data as $values) {?><td > <?php echo $values ?></td><?php } ?></tr>
<?php }
}
echo “</table>”;
?>
It returns character from file pointer
Example
<?php
$fp = fopen(‘test.txt’, ‘r’);
while (!feof($fp)) {
echo fgetc($fp);
}
fclose($fp);
?>