Learning PHP and MySQL

Example 11-21 Checking the permissions of a file

<?php
    $file_name
="permissions.php";

    if(
is_readable($file_name))  {
      
echo  ("The  file  $file_name  is  readable.<br>");
 
}
 
else  {
    
echo  ("The  file  $file_name  is  not  readable.<br>");
 
}
 
if(is_writeable($file_name))  {
   
echo  ("The  file  $file_name  is  writeable.<br>");
 
}
 
if (is_executable($file_name))  {
   
echo  ("The  file  $file_name  is  not  writeable.<br>");
 
}
 
else  {
   
echo  ("The  file  $file_name  is  executable.<br>");
 
}
?>

Our code tells us the many details regarding permissions on the file in Figure 11-17.

Posted by on 08/19 at 08:34 AM

Next entry: Example 11-22 Using file_exists, touch, and unlink together

Previous entry: Example 11-20 The file_exists.php script checks to see if the file is there

<< Back to main