On Tue, 2009-05-26 at 18:30 +0100, hessi...@hessiess.com wrote:
> Something that seriously annoys me about PHP is the fact that it has
> a configuration file which can *completely* change the behaviour of
> the language. Take the following for example:
> ----------------------------------------------
> function parse_to_variable($tplname, $array = array())
> {
>     $fh = fopen($tplname, 'r');
>     $str = fread($fh, filesize($tplname));
>     fclose($fh);
> 
>     extract($array);
> 
>     ob_start();
>     eval($str);
>     $result = ob_get_contents();
>     ob_end_clean();
>     return $result;
> }
> ----------------------------------------------
> 
> Which would take a template file like this (DTD etc left out):
> ----------------------------------------------
>     <p>List:</p>
>     <ul>
>         <?php foreach($array as $item): ?>
> 
>         <li><php echo($item); ?></li>
>         <?php endforeach; ?>
> 
>     </ul>
> ----------------------------------------------
> 
> The above code loads in the template file, eval()'s it and then saves the
> result into a variable, so that it may be intergraed into anouther element
> of a dynamic website, which is a hell of a lot cleaner than the:
> ----------------------------------------------
> echo ("<something>" . $some_variable . "<something_else>" ...);
> ----------------------------------------------
> 
> mess that you find in a lot of PHP code. Not only is it hard to read, but it
> also produces awfully indented HTML, unlike the template method which outputs
> properly indented code and is much easier to read.
> 
> This works perfectly so long as output buffering is enabled, however for some
> reason my web host has decided to disable output buffering in the config
> file,
> rendering the above elegant solution completely useless(*). So, why does PHP
> have to have such a pain in the a$$ configuration file. It makes developing
> platform and even install independent code a nightmare, I am seriously
> considering
> moving to a different language because of this.

Could you tell us what configuration setting they have changed? I wasn't
aware you could prevent the use of output buffering. I guess maybe if
they set output_buffering = 1 to force flushing after a single byte.
Either way, this is not a PHP issue, this is a web host problem. The
blame lies squarely on their shoulders if they have changed how
something fairly standard works. Such settings are usually made
available to people who know what they're doing and who need specific
functionality.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to