Issue
Can anyone explain why the following script behaves differently on two different platforms?
Script:
<?php
echo "hello!";
$view_content = ob_get_clean();
echo "'".gettype($view_content)."' >".$view_content."<";
Output 1 (on WampServer 2i - php v5.3.0 - Windows 7 x64 ):
'string' >hello!<
Output 2 ( on MAMP 1.9 - php v5.3.2 - OSX 10.6.4 ):
hello!'boolean' ><
It seems like MAMP is not performing the function 'ob_get_clean()' correctly. I also tried v5.2.13 of php on MAMP and saw the same problem.
I realize that these are different "versions" of php but i feel like this should work. Is there an extension/module I'm missing?
Solution
Probably on 1 host, automatic output buffering is on. I'd advise against that, as it hogs resources that are not needed most of the time. You can use & set it if you rely on it, a better way IMHO is to just call ob_start()
when the real need arises.
From the manual:
Return Values
Returns the contents of the output buffer and end output buffering. If output buffering isn't active then FALSE is returned.
Answered By - Wrikken
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.