Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • pathinfo() Function

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 132
    Comment on it

    pathinfo() function basically contains the information of the file path. It will take two parameters:

    • path(required) : path whose information is needed.
    • options(optional) :tells which elements to return. Values are PATHINFO_DIRNAME(returns directory name), PATHINFO_BASENAME(return basename), PATHINFO_EXTENSION(return extension), PATHINFO_FILENAME (return filename)

    This function returns an array or string depends upon the value of options. By deafult, all values are returned if options is not set.

    For example:

    <?php
    $path_info = pathinfo('/www/htdocs/demo.php');
    
    echo $path_info['dirname'], "\n";
    echo $path_info['basename'], "\n";
    echo $path_info['extension'], "\n";
    echo $path_info['filename'], "\n"; // since PHP 5.2.0
    ?>
    

    When you will execute the above script it will display:

    /www/htdocs
    demo.php
    php
    demo
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: