FileSystem Function in PHP: PART 3

Introduction

In this article I describe the PHP FileSystem functions "disk_total_space", "diskfgreespace", "fclose" and "feof". To learn some other filesystem functions, go to:

  1. FileSystem Function in PHP: PART 1
     
  2. FileSystem Function in PHP: PART 2

PHP disk_total_space() Function

The PHP filesystem "disk_total_space" function returns the total size of the file system or disk partition.

Syntax

disk_total_space(directory)

Parameter in disk_total_space function

The parameter of the function is:

Parameter Description
directory It specifies the directory to check.

Example

An example of the
function is:

<?
php
echo
"Total space on drive C (in Bytes) is: ";
echo
disk_total_space("C:");
?>

Output 

disk-total-space-function-in-php.gif

PHP diskfreespace() Function

The PHP filesystem "diskfreespace" function is an alias of the "disk_free_space_function" thatalso returns the available space on the file system or disk partition (in bytes).


Syntax

diskfreespace(directory)

Parameter in diskfreespace function

The parameter of the function is:

Parameter Description
directory It specifies the directory to check.

Example

An example of the
function is:

<?
php
echo
"Total Free space on drive C (in Bytes) is: ";
echo
diskfreespace("C:")
?>

Output

diskfreespace-function0in-php.gif

PHP fclose() function

The PHP "fclose" function closes an open file pointer and it returns true on success or false on failure.

Syntax

fclose(file)

Parameter in fclose function

The parameter of the function is:

Parameter Description
file It specifies the file to close.

Example

An example of the
function is:

<?
php
$file = fopen("test.txt","r
");

//some code to be executed
fclose($file);
?>

PHP feof() Function

The PHP "feof" function checks for the end of file pointer returned by "fopen()" and "fsockopen()".


Syntax

feof(file)

Parameter in feof function

The parameter of the function is:

Parameter Description
file It specifies the open file to check.

Example

An example of the
function is:

<?
php
$file1=fopen("test.txt","r
");

do
{
$line=fgets($file1);
echo $line;
echo "<
br/>";
}
while(!feof($file1))
?>


Output

feof-function-in-php.gif


Similar Articles