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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 53
    Comment on it

    The basename() function is used to extract the filename from a path. In other words, the function returns the filename from a path. It contains two parameters:

    • path(Required): it specify the path to check
    • suffix(Optional): It is a optional parameter which specify a file extension. If the filename has this extension then it display the filename without extension.

    For example:

    <?php
    $path = "/var/www/demo.php";
    
    //it will display filename with file extension
    echo basename($path) ."<br/>";
    
    //it will display filename without file extension
    echo basename($path,".php");
    ?>
    

    The output of the above script will be as follows:

    demo.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: