PHP Cannot redeclare function after file name changed

175 views Asked by At

I'm getting this error

Fatal error: Cannot redeclare getAllStaff() (previously declared in /Applications/XAMPP/xamppfiles/htdocs/StaffTools/database/StaffHandler.php:5) in /Applications/XAMPP/xamppfiles/htdocs/StaffTools/database/staffHandler.php on line 15

I'm building an application in Apatana Studio 3 and I renamed a file from staffHandler.php to StaffHandler.php (uppercase S) so the former no longer exists.

I get all my PHP files from the database directory using the below PHP code

foreach(glob("database/*.php") as $filename) {
    include $filename;
}

And then call a method called getAllStaff() here:

        <select name="staff">
            <?php getAllStaff(); ?>
        </select>

Obviously, this method is now in StaffHandler.php. This was working fine until I changed the filename of the name.

Things I've tried

  1. Clearing my cache in Firefox
  2. Rebuilding & cleaning my project in Aptana
  3. Changing the filename back to staffHandler.php
  4. Conditional function statemet if(!function_exists....

Why on earth would PHP throw an error like that for a file that doesn't exist anymore?

UPDATE: RESOLVED

I had a reference to the staffHandler.php file buried within all my PHP scripts and I think this was the source of the problem. When I ran ls -la at the terminal in the database directory only StaffHandler.php appeared but when I ran find staffHandler.php and rm staffHandler.php it erased both staff and Staff. Must've been some kind of link between created by application code.

0

There are 0 answers