Note that there are some explanatory texts on larger screens.

plurals
  1. POFunction using output buffer works in dev but not prod
    primarykey
    data
    text
    <p>I use this function in my views to position various content blocks.</p> <pre><code>function block(&amp;$block = false) { if ($block === false) return ob_end_clean(); return ob_start(function($buffer) use (&amp;$block) { $block = $buffer; }); } </code></pre> <p>I never had problem with it until today. My blocks don't show up on this particular project.</p> <p>Dev environment: PHP 5.3.3-7+squeeze17 with Suhosin-Patch (cli) (blocks show up)</p> <p>Production environment where script fail (silently): PHP 5.4.4-14+deb7u5 (cli) (blocks don't show up)</p> <p>PHP logs don't show anything.</p> <p>Can you help me find what is going on?</p> <p><strong>EDIT:</strong></p> <p>A bit more information on how I use this function.</p> <p>Say I have a basic view <code>page.php</code></p> <pre><code>&lt;h1&gt;&lt;?= $title ?&gt;&lt;/h1&gt; &lt;div class="content"&gt; &lt;?= $content ?&gt; &lt;/div&gt; &lt;?php block($scripts) ?&gt; &lt;script&gt; // javascript here &lt;/script&gt; &lt;?php block() ?&gt; </code></pre> <p>Then in my layout file <code>html.php</code></p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; ... &lt;?php if (isset($scripts)) print $scripts ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>EDIT2:</strong></p> <p>I use this class for my views.</p> <pre><code>class view { public static $globals; public function __construct($file, $layout = null) { $this-&gt;file = $file; if ($layout !== null) $this-&gt;layout = $layout; } public function __toString() { extract((array)self::$globals); extract((array)$this); start: ob_start(); include PATH_VIEWS . $file; if (!isset($layout)) return ob_get_clean(); $view = ob_get_clean(); $file = $layout; unset($layout); goto start; } } die(new view('page.php', 'html.php'); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload