PHP Tutorial: Get Filename From Domain Path

Comments 2 Standard

<?php
/****
* Purpose: get the filename from the path
* Precondition: path i.e. http://domain.com/contacts.php
* Postcondition: returns the filename i.e. contacts.php
****/
function fileName($path)
{
     return substr($path, strrpos($path, '/')+1, strlen($path));
}
?>

Programming Challenge Main Page or Continue to Day 3

Advertisements

2 thoughts on “PHP Tutorial: Get Filename From Domain Path

  1. Pingback: Programming Challenge: 31 Code Snippets in 31 Days « Online Game Development

  2. Pingback: Programming Challenge Day 1: Format Dates Taking Country Into Consideration « Online Game Development

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s