Re: RFC: Selecting Namespaces and Tag styles at include time. ( was Re: PHP Dev RFC Selecting Namespaces and Tag styles at include time.)
| From: | Stanley Sufficool | Date: | Sat, 18 Dec 2010 04:27:45 +0000 |
| Subject: | Re: RFC: Selecting Namespaces and Tag styles at include time. ( was Re: PHP Dev RFC Selecting Namespaces and Tag styles at include time.) | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51071@lists.php.net to get a copy of this message | ||
I would go with a maskable enumeration for multiple options support:
Val Constant
0 PHP_TAGS_NONE
1 PHP_TAGS_LEGACY
2 PHP_TAGS_STANDARD
4 PHP_TAGS_SHORT
8 PHP_TAGS_SCRIPT
16 PHP_TAGS_ASP
So that if I want to use mixed tags (<?php and <?) then I can set
tag_style = PHP_TAGS_SHORT | PHP_TAGS_STANDARD
or
tag style = 6
IMHO, I think is more flexible and understandable.
On Fri, Dec 17, 2010 at 10:09 AM, Michael Morris <dmgx.michael@gmail.com> wrote:
> I've been giving some thought to the implication of my off the cuff addition
> of PHP_TAGS_NONE to the modes allowed and what should logically go with
> that. If tag style can be declared in a function, it should be possible set
> them in the configuration and at other places. Currently tag style is spread
> over multiple settings in the configuration - I know of two:
>
> asp_tags
> short_open_tag
>
> This is problematic moving forward so I hereby suggest nipping further
> proliferation in the bud and go to one configuration setting with this name:
>
> tag_style
>
> It's values, and their corresponding meaning:
>
> Val Constant Effect
> 0 PHP_TAGS_LEGACY Honor older ini tag settings such as asp_tags
> or short_open_tag, in all ways behave in a
> a manner compliant with the expectations of
> any scripts that are upgrading.
> 1 PHP_TAGS_NONE No tags will be permitted in the file.
> Interpreter expects the whole file to be
> PHP.
> 2 PHP_TAGS_STANDARD Enable the classic <?php ?> tags we all know
> and love.
> 3 PHP_TAGS_SHORT Use PHP short tags <? ?> and <?= ?>. Unlike
> Legacy behavior with short_open_tag set to
> 'on' this setting will NOT let you use
> <?php ?> alongside the <? ?> and <?= ?>
> tags.
> 4 PHP_TAGS_SCRIPT Script tags <script type="php"></script>
> 5 PHP_TAGS_ASP ASP style tags <% %>
>
> And so a script could have an .htaccess file with
>
> php_flag php_tags 1
>
> So the first file the webserver reads in doesn't have to have any opening
> tag at all. This would put a stop to the puzzlement of "Why am I getting an
> error when I call header()" which I see on programming boards at least once
> a week.
>
> The constants above can in turn be coupled to my original recommendation
> that include, include_once, require, and require_once each be allowed to
> have a second parameter. The default value of the second parmeter is
> whatever php_tags is set to at the time the include statement is parsed.
>
> Hence, unlike the current situation with short_open_tag and asp_tag,
> php_tags can be changed at runtime using ini_set. The only catch is the
> change only affects includes which occur after the setting change.
>
> I believe strongly that this improved recommendation improves the
> interoperability of tag styles without creating backwards compatibility
> issues or creating future problems. As for the secondary suggestion I made,
> allowing namespaces to be specified in the include statement, I'll drop that
> from this recommendation to focus on the changes to tag style setting.
>