PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 18, 2022

[FIXED] ob_get_clean() is not working on MAMP but works on WampServer?

 February 18, 2022     mamp, php, wamp, wampserver     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing