note 16966 added to functions

From: Date: Tue, 20 Nov 2001 16:19:15 +0000
Subject: note 16966 added to functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-21066@lists.php.net to get a copy of this message
For some reason, functions have a serious problem obtaining global accesses to resources, such as databases. $conn = anyPHPdatabaseOpen(...); function useDb() { global $conn; statement_using_connection( $conn ); // The doesn't work, but should. } Because of this, you need to pass the resource (in this case $conn) as a parameter. function useDb( $conn ) { ... } -- http://www.php.net/manual/en/functions.php http://master.php.net/manage/user-notes.php?action=edit+16966 http://master.php.net/manage/user-notes.php?action=delete+16966 http://master.php.net/manage/user-notes.php?action=reject+16966

« previous php.notes (#21066) next »