global and resource handle
| From: | Przem Kowalczyk | Date: | Tue, 29 Aug 2000 13:34:18 +0000 |
| Subject: | global and resource handle | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-14116@lists.php.net to get a copy of this message | ||
Hi
It started with a postgresql problem. So I asked Jouni Ahto (thanks for
your help with isolating problem :-) ) and isolated problem:
(latest php-devel)
If I write the following code entirely into page (without making a
function)
if (!is_object($user))
{
$user = new User($userbase);
}
session_register('user');
$user -> eBase();
everythig works perfectly
if I change it into:
sess_start()
......
function sess_start()
{
global $userbase;
global $user;
if (!is_object($user))
{
$user = new User($userbase);
}
session_register('user');
$user -> eBase();
}
the base handle that is established in $user -> eBase() is silently
casted from resource to integer, that couse many problems.
It looks for me like a problem with 'global'. Also if i try to
echo serialize($user)
i see, that base handle is an integer :-(
Is it a bug or am I doing something wrong?
Przem