note 22504 added to functions

From: Date: Thu, 20 Jun 2002 13:51:20 +0000
Subject: note 22504 added to functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-32042@lists.php.net to get a copy of this message
I have some problems with functions. I want to create some kind of 'tell me the configuration function'. Like this: <?php function TellConfig(){ $header_file_to_use = "header.inc"; $footer_file_to_user = "footer.inc"; } //Wont Work! TellConfig(); include($header_file_to_use); echo "Body!"; include($footer_file_to_use); /* Is there a way to call a variable set by a function? As i dont know this is the way i am doing it */ $header_file_to_use = ""; $footer_file_to_use = ""; function TellConfig2(){ global $header_file_to_use, $footer_file_to_use; $header_file_to_use = "header.inc"; $footer_file_to_use = "footer.inc"; } TellConfig2(); include($header_file_to_use); echo "body 2!"; include($footer_file_to_use); // This works ?> Even i dont want to use a function for configuration vars this is a good example. :P -- http://www.php.net/manual/en/functions.php http://master.php.net/manage/user-notes.php?action=edit+22504 http://master.php.net/manage/user-notes.php?action=delete+22504 http://master.php.net/manage/user-notes.php?action=reject+22504

« previous php.notes (#32042) next »