#23385 [Opn->Fbk]: Problem with object assignment and the :: operator in a function.
| From: | moriyoshi@php.net | Date: | Mon, 28 Apr 2003 17:35:26 +0000 |
| Subject: | #23385 [Opn->Fbk]: Problem with object assignment and the :: operator in a function. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-38638@lists.php.net to get a copy of this message | ||
ID: 23385
Updated by: moriyoshi@php.net
Reported By: jon at lightsky dot com
-Status: Open
+Status: Feedback
Bug Type: Scripting Engine problem
Operating System: linux
PHP Version: 4.3.1
Previous Comments:
------------------------------------------------------------------------
[2003-04-28 12:34:40] moriyoshi@php.net
"test 4" seems simply wrong: as far as I see your snippet, the $bla
variable is neither initialised in global scope nor imported with
"global" statement. And
echo '<br >Test 2 ' . ($bla?= Mail::factory ...
^
is this a typo?
------------------------------------------------------------------------
[2003-04-28 12:11:45] jon at lightsky dot com
I am having trouble assigning new objects returned from a method called
with the :: operator.
Here is the code that I am running.
// PEAR mail object
require_once ('Mail.php');
require_once ('Mail/sendmail.php');
// the function that i am running
function send_notification ($intraval) {
// Create the mail object using the Mail::factory method for send
mail
$params['sendmail_path']='/usr/lib/sendmail';
echo 'Test 1 ' . (Mail::factory('sendmail',$params));
echo '<br >Test 2 ' . ($bla = Mail::factory('sendmail',$params));
echo '<br >Test 3 ' . ($bla);
echo '<br>Test 4 ' . $GLOBALS['bla'];
// try creating the obj without the :: operator
$send_mail = new Mail_sendmail ($params);
echo '<br >Test 5 ' . $send_mail;
}
// attempt to run my function
send_notification (1);
It outputs This:
Test 1 Object
Test 2 Object
Test 3
Test 4
Test 5 Object
You can see that when I echo the results returned from the
Mail::factory method in test 1 and 2 I get an object. However, when I
attempt to echo the variable assigned from Mail::factory--tests 3 and
4--i get nothing. In test 5 i created an object using 'new' and it is
assigned just fine.
I don't know if this is really a bug but I don't know at this point
what else it could be.
Complied Modules:
'./configure' '--with-gd' '--with-pgsql=/usr/local/pgsql/'
'--with-ldap' '--prefix=/usr/local/apache/php'
'--with-apxs=/usr/local/apache/bin/apxs' '--with-zlib-dir=/usr/lib'
'--with-config-file=/usr/local/apache/lib/'
On a side note I was searching for bugs with '::' and the search
removed '::' from my search. I don't know if it is possible to allow
'::' as a search string but it was quite a bit harder to find similar
bugs when the main condition I was trying to match was removed
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23385&edit=1