views:

96

answers:

3

so i am using PHPExcel (http://phpexcel.codeplex.com/) to import a excel sheet. everything works fine on my development system, BUT it doesn't quite work on the live system.

hence i debugged and looked what could be wrong. i got to a point where i found that a method obviously returned NULL, where it should have returned an object. i looked into that method, and var_dump()ed the var which was returned in the method. the var was NOT NULL

PSEUDO CODE:

class Bar()  
{  
 function methodInAClass()  
 {  
    $test = new Foobar;  
    [...]
    /* $test was an object here with a lot of data (var_dump()
     * took around 100.000 lines in an editor) */
    var_dump($test); 
    return $test;   
 }  
}  

$bar =& new Bar();  
$test2 = $bar->methodInAClass(); //$test2 is NULL here

what am i doing wrong? is this a problem that comes from the php.ini?!

A: 

I see no reason for this happen. Unless you're doing something funny you're not showing us, I don't see how you could check this out without a native debugger, where you could, for instance, put a data breakpoint on the contents of the object.

And by the way, there's no reason you should do $bar =& new Bar(); instead of $bar = new Bar(); (in PHP5); in fact, the former is deprecated.

Artefacto
I think you mean it vice versa, don't you? *there's no reason you should do $bar = ** instead of $bar = new Bar();*
Felix Kling
@Fel yes; I've fixed it, thanks.
Artefacto
A: 

PHP shouldn't care how big the returned value is if it's the actual object being returned (as it is in this case). More explicit detail might help, because your quoted example should work without issue... I have some familiarity with PHPExcel. What version are you using? What object are you returning? (IIRC there isn't a Foobar object in the library) Are you using any memory caching?

Mark Baker
+1  A: 

a higher memory limit seems to have fixed the issue!

wookie
This sounds like a bug, to be honest. If it's because it's running out of memory then you should get an error and not corrupted data. Try submitting a bug to http://bugs.php.net
Daniel Egeberg