I have a discussion going on in the PHP Internals list regarding the future of tag setup that is showing some promise and I’d like to get some wider input and get it some momentum because I think I and the people I’ve been speaking with have hit upon something nice.
Basically a new php ini configuration would be added
php_tag_style
It would be a bit field. Bit 0 determines if the legacy tag behavior is implemented (0) or if no tags at all are implemented unless specified higher in the bitmask (1). So if you upgraded to php with this setting and set php_tag_style = 1 you would not have to use php tags in your php files – but you wouldn’t be able to use tags either. The higher bits correspond to tag styles
bit 1 – normal tags (<?php ?>)
bit 2 – short tags (<? ?>)
bit 3 – asp tags (<% %>)
bit 4 – short echo (<?php=, <?=, <%= )
bit 5 – script tags (<script type=“php”> </script> )
And if necessary more could be added. Tag style can be set in php.ini, in httpd.conf of htaccess, or at runtime. When the tag style is changed the setting affects all furture include and require statements - any that have already parsed will be unaffected.
Additionally, the include, require, include_once and require_once statements can take the same bitfield mask as a second argument to instruct them on how the file to be included will be parsed. Hence
include( ‘file.php’, 20 );
Would include a file using short tag parsing rules in addition to the standard file parsing rules. PHP_TAG constants would be added to make this more readable - allowing the statment to read as
include( ‘file.php’, PHP_TAGS_SHORT )
Still hammering this out in the discussion, but I think it adds a lot of flexibility as well as allowing for PHP libs to be written entirely tagless, which in an MVC framework is usually going to be 2/3rds of the framework.