php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23385 Problem with object assignment and the :: operator in a function.
Submitted: 2003-04-28 12:11 UTC Modified: 2003-04-28 12:50 UTC
From: jon at lightsky dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.1 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jon at lightsky dot com
New email:
PHP Version: OS:

 

 [2003-04-28 12:11 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-28 12:34 UTC] 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:44 UTC] jon at lightsky dot com
echo '<br >Test 2 ' . ($bla?= Mail::factory ...
                           ^
I have no idea what that is.  It shows up as white space in my editor. However when i deleted it the script works. So sorry to bother you with this problem.
 [2003-04-28 12:50 UTC] moriyoshi@php.net
Not a PHP bug => bogus

P.S. it's likely that the character you see as a white space is not a *real* space, but the one technically referred to as NBSP.

 [2003-04-28 12:50 UTC] moriyoshi@php.net
.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 06:00:01 2026 UTC