Re: UPDATED RFC version 1.1: source files without opening <?php tag
| From: | Luke Scott | Date: | Wed, 11 Apr 2012 00:19:17 +0000 |
| Subject: | Re: UPDATED RFC version 1.1: source files without opening <?php tag | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-59691@lists.php.net to get a copy of this message | ||
On 4/10/12 4:53 PM, "Tom Boutell" <tom@punkave.com> wrote:
>Please see:
>
>https://wiki.php.net/rfc/source_files_without_opening_tag
>
>After following the discussion I have updated the RFC with the
>following major changes:
>
>* Forbade the use of ?> entirely in "pure PHP" files (without
>restricting it at all in other PHP files)
>
>* Replaced my original new require_path keyword with a second,
>optional parameter to the standard include/require family of keywords
>
>* Replaced an array of options with a bitwise OR of options
>
>* Changed the proposed filename extension from .phpc (which apparently
>is in use somewhere, maybe?) to .phpp ("php pure")
Looks good, however:
- I would like to see an INCLUDE_SILENT method to prevent warnings from
being thrown with include/include_once statements. Currently doing
something like @include "/path/to/file.php"; not only hides these
warnings, but warnings/errors/notices thrown by the file itself. An
INCLUDE_SILENT flag would be extremely helpful in some situations.
Example:
if(class_exists("MyClass")) // Auto loader is used
{
// Class exists, continue normal...
}
else
{
// Class doesn't exist, do stuff... but warnings are being thrown!
Eeek!
}
(An INCLUDE_SILENT is probably the most important to me)
- The INCLUDE_ONCE and INCLUDE_ERROR_ON_FAILURE are a bit redundant.
Wouldn't you just use require or include_once/require_once?
- Not sure I like the word "pure code". I would prefer just "code" -
INCLUDE_CODE. Perhaps even just "pure" - INCLUDE_PURE. I just don't like
two words. Would also like another flag for the other mode, such as
INCLUDE_TEMPLATE or INCLUDE_EMBED.
- I would like to be able to specify the mode as an environmental variable
from the web server, perhaps "PHP_MODE". So I could do something like this
in my Nginx config:
location / {
fastcgi_pass unix:/Server/tmp/php-fpm.sock;
include fastcgi_params;
fastcgi_param PHP_MODE "pure";
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_param HTTP_ACCEPT_ENCODING "";
fastcgi_param HTTPS $https;
}
Luke