SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP File Function

pathinfo function to get file details of a file path

We can use pathinfo to get details of the file path. We can input a file path and get the directory name, basename (file name with extension), file name without extension and the file extension. The function pathinfo returns an array.

<?Php
//$file = $_SERVER["SCRIPT_NAME"]; // Takes the current file name
$file='http://127.0.0.1/t/file/path.php'; // Path is stored in Variable
$path_details=pathinfo($file);
//echo print_r($path_details);
echo $path_details['dirname']; // Output is: <i>http://127.0.0.1/t/file</i>

echo "<br>";
echo $path_details['basename']; // Output is: <i>path.php</i>
echo "<br>";
echo $path_details['extension']; // Output is: <i>php</i>
echo "<br>";
echo $path_details['filename']; // Output is: <i>path</i>

?>

Be the first to post comment on this article :


Google+
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer