Share on Google+Share on Google+

PHP basename() function, PHP basename function example

Advertisement
PHP base name function example code. Learn how to use basename() function in your PHP program.

In this section we will learn about the basename() function of php

This example of basename()  function in PHP

Description about PHP basename():

syntax for PHP basename()Function

string basename ( string $path [, string $suffix ] )

On giving the $path value with the file name with path it will return base file name .

if suffix is given then suffix will not come in result

Code:

<?php

$base1=basename("c:\rose1\ss.java",".java");

echo $base1;

?>

Program output:

ss

Code:

<?php

$base1=basename("c:\rose1\ss.java","");

echo $base1;

?>

Program output:

ss.java

 

Advertisements

Advertisement

Posted on: September 16, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.