#19140 [Bgs]: pg_pconnect opens a new connection even when and old one is available

From: Date: Wed, 28 Aug 2002 08:48:59 +0000
Subject: #19140 [Bgs]: pg_pconnect opens a new connection even when and old one is available
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-18006@lists.php.net to get a copy of this message
ID: 19140 User updated by: jc@mega-bucks.co.jp -Summary: foreach fails on empty or uninitialized variable Reported By: jc@mega-bucks.co.jp Status: Bogus Bug Type: Arrays related Operating System: Red Hat Linux 7.2 PHP Version: 4.2.2 New Comment: $a is an unitialized variable. It is not an empty variable ($a = ""). It is declared but not initialized. It has no value since the function returns nothing. The problem is that PHP cannot tell that $a is supposed to be an array since $a has no value or content whatsoever. Previous Comments: ------------------------------------------------------------------------ [2002-08-28 04:41:31] cynic@php.net "an uninitialized array"? i don't see anything like that in your example. there's just one nonexistent (null, if you must) variable. no array. ------------------------------------------------------------------------ [2002-08-28 04:37:12] jc@mega-bucks.co.jp The following code generates an error/warning: $a = return_nothing(); foreach ($a as $val) { echo "hi"; } function return_nothing() { } OUTPUT: Warning: Invalid argument supplied for foreach() in test.php on line 5 The documentation does not state what the correct/expected behaviour of foreach should be in the case of an unitialized array. It would be nice if foreach could recognize unitialized variables as being equivalent to "empty" arrays ... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19140&edit=1

« previous php.bugs (#18006) next »