Re: PHP class files without <?php at the top

From: Date: Sat, 07 Apr 2012 17:23:39 +0000
Subject: Re: PHP class files without <?php at the top
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 07/04/12 17:22, John Bafford wrote:
> On Apr 7, 2012, at 10:53, John Crenshaw wrote:
>> What if you have just ONE function with a variety of options? Something like:
>>
>> execute_file('path/to/foo.php', array(
>>    'require'=>true,
>>    'once'=>true,
>>    'begin_code'=>'<?php ',
>>    'shorttags'=>array('<?=','?>'),
>>    'autoescape'=>function($str){return htmlentities($str, ENT_QUOTES |
>> ENT_HTML5, 'UTF-8');},
>>    ...
>> ));
> While there's some elegance with your execute_file (there'd definitely be benefits to
> one function instead of the four we have now), the extra options would spawn so much Daily WTF
> material it wouldn't be funny, and I think most people would just stick with
> include/require/*_once because there'd be a lot less effort in the common case.
I agree that the free-form tags could lead to much Daily WTF material,
but there's a simplett reason to reject it: The tags are hardcoded in
the lexer.
Making it anything can drop perfomance.

However, they could be possible as booleans, just as many of them are
now in php.ini.
And I like the idea of providing a function for auto escaping <?= echos.



Thread (70 messages)

« previous php.internals (#59431) next »