Re: [RFC] Pure-code source files via the .phpc extension
| From: | Hendrik Mennen | Date: | Wed, 17 Jun 2026 04:21:07 +0000 |
| Subject: | Re: [RFC] Pure-code source files via the .phpc extension | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131340@lists.php.net to get a copy of this message | ||
> Am 17.06.2026 um 02:58 schrieb Michael Morris <tendoaki@gmail.com>:
>
>
>
> On Tue, Jun 16, 2026 at 7:02 PM Sarina Corrigan <sarina.corrigan@gmail.com
> <mailto:sarina.corrigan@gmail.com>> wrote:
>>
>>
>> On Tue, Jun 16, 2026, 18:22 Michael Morris <tendoaki@gmail.com
>> <mailto:tendoaki@gmail.com>> wrote:
>>> Here's a thought - Instead of .phpc as an extension, why not <?phpc or even
>>> <?psf (PHP source file). Explicitly tell the engine "nothing should be before this other
>>> than a shebang, no further tags will be in this file.
>>>
>>> That also solves the inadverted echo problem and would be fully BC.
>>>
>>> Not convinced it would be useful, but it has fewer problems.
>>
>>
>> I could actually get behind an alternative tag that reads everything as PHP. It would at
>> least solve the problem of accidental output prior to the opening tag, though I'm not sure how
>> big of a problem that really is. Could we expect any performance benefits from not having to parse
>> for any closing tags? I imagine it would be minuscule if anything
>
> Thinking on this a bit more, if it is an independent tag it could hold directives on how the
> file should be parsed.
>
> <?psf strict ?> Parse the file with strict mode. Here the closing tag means we're
> done passing directives, no further tags will be allowed in the file and the parser will remain in
> PHP mode for this file.
>
> <?psf new_scope ?> Create a new scope - that is no variables, symbols or autoloaders will
> be shared with the file that included this one. This is an alternate way to do containers aside from
> creating a new function.
>
> Thoughts?
Hm my core idea was, to get PHP a bit more like C#, Python and so on - they also don’t have a
start -/ end tags
But as a first goal, your idea seems logical
Hendrik