Can I delete a function declaration?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Can I delete a function declaration?

Post by AGISB »

Here is my problem. I am using a custom session handler which uses the function showerror(). Now the problem comes on my logout page. I destroy the session and wants to start a new one. I get following error as the handler calls that function again.

Fatal error: Cannot redeclare showerror()

Is there any way I can delete that function declaration?



I know a solution to the problem as I can do a session_regenerate() instead of deleting and restarting but I want to know if I could do it another way.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

require_once() or include_once()

Those two prevent repeat declarations.
PHP Manual wrote:require_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
Post Reply