how to get file info path and extension php


Here you will find a  free php scripts, php resources, php tutorials, web resources , jquery



<?php print "welcome to source world-php script"; ?>

Since php  4 and  php 5 you can get all information about given path using php inbuilt function  pathinfo().









SYNTAX :

pathinfo ( string $path [, int $options = PATHINFO_DIRNAME | PATHINFO_BASENAME |       
PATHINFO_EXTENSION | PATHINFO_FILENAME ] )

path:      The path being checked.

options :You can specify which elements are returned with optional parameter options. It composes from           
PATHINFO_DIRNAME, PATHINFO_BASENAME, PATHINFO_EXTENSION and PATHINFO_FILENAME. It defaults to return all elements.
 
Return : The associative array elements are returned: dirname, basename, extension (if any), and filename.
If options is used, this function will return a string if not all elements are requested.
 

$path_parts = pathinfo('/www/htdocs/inc/lib.inc.php');

echo $path_parts['dirname'], "\n";
echo $path_parts['basename'], "\n";
echo $path_parts['extension'], "\n";
echo $path_parts['filename'], "\n"; // since PHP 5.2.0

Buy Me a Beer-If you are like this post

 If you does not have paypal account create free account create account

No comments:

Post a Comment