PHP: how to avoid redeclaring functions?

hhh picture hhh · Sep 5, 2009 · Viewed 33.3k times · Source

I tend to get errors such as:

Fatal error: Cannot redeclare get_raw_data_list() (previously declared in /var/www/codes/handlers/make_a_thread/get_raw_data_list.php:7) in /var/www/codes/handlers/make_a_thread/get_raw_data_list.php on line 19

how can I avoid the error? Is it possible to create a IF-clause to check whether a function is declared before declaring it?

Answer

Dooltaz picture Dooltaz · Sep 5, 2009
if(!function_exists("get_raw_data_list")) {
... define function here ...
}

http://us.php.net/function_exists