Re: ob_start() and a callback function within a class,not updating ob_get_level().
| From: | Mathijs | Date: | Wed, 22 Nov 2006 08:57:47 +0000 |
| Subject: | Re: ob_start() and a callback function within a class,not updating ob_get_level(). | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-245018@lists.php.net to get a copy of this message | ||
Richard Lynch wrote:
On Thu, November 16, 2006 7:35 am, Mathijs wrote:To give an small example see below. The first file is the class file. Lets pretend the 'MyFunctions' class is included already. In index1 the ob_get_level() get the wrong count. In index2 however the ob_get_level() get the right count. Example: -- File: class.MyFunctions.php -- <?php class MyFunctions { public static function myObCallback($buffer) { return 'Sample<br>'.$buffer.'<br>Sample'; } //Several other functions etc.. etc.. } ?> File: index1.php -- <?php ob_start(); //ob_get_level == 1 - This is correct. ob_start(array('MyFunctions', 'myObCallback')); //ob_get_level == 1 - This should be 2. ?> File: index2.php -- <?php function myObCallback2($buffer) { return 'Sample2<br>'.$buffer.'<br>Sample2'; //Or this. Works also. //return MyFunctions::myObCallback($buffer); } ob_start(); //ob_get_level == 1 - This is correct. ob_start('myObCallback2'); //ob_get_level == 2 - This is correct as it should be. ?>I have a question about ob_start() and ob_get_level(). When i use ob_start(), and then check ob_get_level(), it shows me 1. This is a normal behavior. Now when i do the following ob_start(array('ClassName', 'ClassMethod')). It does execute the methode, but it doesn't update ob_get_level(). Is this a normal behavior?Can you show us where/how you checked ob_get_level()? Cuz I don't really understand what the OOP stuff should do for a callback, and would have to re-read the docs, but my first guess is you do the ob_get_level() after the buffer is all done and the callback is finished and gone, so the level is back to 0...