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

From: Date: Wed, 28 Aug 2002 09:17:21 +0000
Subject: #19140 [Opn->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-18011@lists.php.net to get a copy of this message
ID: 19140 Updated by: cynic@php.net Reported By: jc@mega-bucks.co.jp -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Red Hat Linux 7.2 PHP Version: 4.2.2 New Comment: if you insist on neglectful coding, lower your error_reporting level. Previous Comments: ------------------------------------------------------------------------ [2002-08-28 05:11:43] jc@mega-bucks.co.jp What is the documented/expected behaviour for foreach on "null" arrays? PHP has not problems with statements such as: echo "$a"; So I don't see why it should have a problem with: foreach ($a as $val) {}; Actaully I *do* understand why it is a problem :) I just would like it to suggest that foreach be able to handle null arrays. It would be *such* a nice feature ;) ------------------------------------------------------------------------ [2002-08-28 04:48:58] jc@mega-bucks.co.jp $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. ------------------------------------------------------------------------ [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 (#18011) next »