PHP Classes

Unset variable $dirname on line 242 produces output

Recommend this page to a friend!

      dUnzip2  >  All threads  >  Unset variable $dirname on line 242...  >  (Un) Subscribe thread alerts  
Subject:Unset variable $dirname on line 242...
Summary:PHP classes should be authored with the maximum error reporting
Author:Ben Johnson
Date:2010-07-29 17:08:24

  1. Unset variable $dirname on line 242...   Reply   Report abuse  
Ben Johnson - 2010-07-29 17:08:24
Line 242 of is:

$dirname = ($dirname!='.')?dirname($fileName):'';

When PHP error reporting is configured to report warnings, this line produces output (because it is possible for $dirname not to be set). For this reason, un-zipping a file and then redirecting with header() fails in such situations. The fix would be to set $dirname to an empty string before this line, or suppress the warning with the @ operator:

$dirname = @($dirname!='.')?dirname($fileName):'';