English 中文(简体)
return var doesn t work when var is huge?
原标题:

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 higher memory limit seems to have fixed the issue!

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?

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.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签