Advertisement

02.19.2008 at 05:09AM PST, ID: 23174165
[x]
Attachment Details

Undefined index

Asked by matthew016 in PHP Scripting Language

Hi,

I created a function that returns the extension of a file:

      public static function getFileExtension($fileName) {
            $pathInfo = pathinfo($fileName);
            return $pathInfo['extension'];
      }

But when the file has no extension, I get the Notice: Undefined index: extension

I do not want such an error and rather return an empty string in the function.

Thank you.Start Free Trial
[+][-]02.19.2008 at 05:10AM PST, ID: 20927893

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Sign Up Now!
Solution Provided By: Roonaan
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628