|
File Directories pathinfo(.....), dirname(), filename(), |
| This example uses the key words: pathinfo(.....), dirname(),
filename(), array pathinfo(string path); The path info() function creates an associative array containing three components of the path specified by these three key words like basename, filnename, extension. |
| <html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Using basdename key word</title> </head> <body text="#FFFF00" bgcolor="#000080"> <?php //C:\Apache2\htdocs\php5\tutorials_example\file_directories\basename $path = "C:/Apache2/htdocs/php5/tutorials_example/file_directories/basename/mytext.txt"; print ("The name of the file with extention is : ". $filename = basename($path). "<br/>"); // $filename contains "users.txt" print ("The name of the file with_out extention is : ".$filename2 = basename($path). ".txt"."<br/>"); // $filename2 contains "users" print ("full path : ". $dirname = dirname($path)); ?> <?php //C:\Apache2\htdocs\php5\tutorials_example\file_directories\basename $pathinfo = pathinfo ("http://manas8x/php5/tutorials_example/file_directories/basename/basename.php"); print ("<p/>Dir-name is : ". $pathinfo[dirname]. "<br/>"); // $filename contains "users.txt" print ("Base-name : ".$pathinfo[basename]."<br/>"); // $filename2 contains "users" print ("Extension : ". $pathinfo[extension]); ?> </body></html> |
![]() |
| link |