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));


    $result = ob_get_contents();
    return $result;

Which would take a template file like this (DTD etc left out):
        <?php foreach($array as $item): ?>

        <li><php echo($item); ?></li>
        <?php endforeach; ?>


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
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
moving to a different language because of this.

(*) This could be implemented by saving the variables as XML, making a POST
request to another script, which would then convert the XML back into an
array, eval() the template and send the result back to the first script
`as if' it was sending to a browser. The first script would then capture
the result as a variable. While this would also work, it would be unnecessary
complicated and very slow in comparison, It is *still* dependent on the
in the config file.

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to