PHP/File Directory/dirname

Материал из Web эксперт
Перейти к: навигация, поиск

dirname.php

   <source lang="html4strict">

<?php

  $path = "/home/www/data/users.txt";
  $dirname = dirname($path); // $dirname contains "/home/www/data"

?>

 </source>
   
  


Use dirname() with predefined variable $SCRIPT_FILENAME to obtain the complete path of the script executing the command

   <source lang="html4strict">

<?

  $dir = dirname($SCRIPT_FILENAME);
  print $dir;

?>

 </source>