Skip to content
#externals
← All RFCs
Obsolete

Deprecate PHP's Short Open Tags

by George Peter Banyard

v0.1 · created 2019-03-20 · targets PHP 7.4

wiki.php.net/rfc/deprecate_php_short_tags ↗

implementation
Contents
  1. Introduction
  2. Proposal
  3. Reasoning
  4. Backward Incompatible Changes
  5. Proposed PHP Version(s)
  6. RFC Impact
  7. To SAPIs
  8. To Existing Extensions
  9. To Opcache
  10. php.ini Defaults
  11. Unaffected PHP Functionality
  12. Feedback
  13. Proposed Voting Choices
  14. Vote
  15. Patches and Tests
  16. Implementation
  17. References

Introduction

PHP has provided over the years different ways to indicate the beginning of PHP code other than the standard <?php ... ?> open tags. Most of these opening tags have been removed with PHP 7.0.01), however, PHP's short open tags still remain.

Proposal

Deprecate and disable short_open_tag in PHP 7.4 and remove PHP's short open tags in PHP 8.0.

Reasoning

  • The PHP documentation discourages their usage.
  • PHP's short open tags clash with XML <?xml ?> and can mean two different things depending on the INI configuration.
  • PHP's short open tags depend on an INI directive and as such are non-portable.
  • As such source code may leak if PHP relying on the short open tags is executed on a configuration where this isn't enabled.
  • PHP's parser simplification.

Backward Incompatible Changes

Every script which currently uses the discouraged short <? open tag will need to convert to the standard <?php open tag. This can be automatically achieved by using the “full_opening_tag” fixer from PHP-CS-Fixer.

Proposed PHP Version(s)

Deprecation notice and default value changed to Off in PHP 7.4 and removal in PHP 8.0.

RFC Impact

To SAPIs

None.

To Existing Extensions

Readline and Tokenizer have been updated in the implementations patches.

To Opcache

None to my understanding.

php.ini Defaults

Change short_open_tag from “1” to “0”.

Unaffected PHP Functionality

The <?= short tag is unaffected because as of PHP 5.4 it is always available.

Feedback

Facebook poll 2) created by Peter Kokot: 73 for, 2 against.

Proposed Voting Choices

Yes/No for boths votes.

Vote

Primary vote: Deprecate PHP's short open tags in PHP 7.4. Requires a 2/3 majority.

Secondary vote: Remove PHP's short open tags in PHP 8.0. Requires a 2/3 majority.

Voting started on 2019-04-10 at 10:40 UTC and ran until 2019-04-24 11:20 UTC (for two (2) weeks)

Vote: Deprecate PHP short open tags in PHP 7.4? — Yes: 38 · No: 18 (closed)

Vote: Remove PHP short open tags in PHP 8.0? — Yes: 42 · No: 15 (closed)

Patches and Tests

https://github.com/php/php-src/pull/3972 PHP 7.4 Deprecation Notice Implementation https://github.com/php/php-src/pull/3975 PHP 8.0 Removal Implementation TBD Documentation patch

Implementation

After the project is implemented, this section should contain

  1. the version(s) it was merged into
  2. a link to the git commit(s)
  3. a link to the PHP manual entry for the feature
  4. a link to the language specification section (if any)

References

Initial feedback on Internals (link to External.io) RFC Announcement on Internals (link to External.io) RFC Vote Announcement on Internals (link to External.io)

1)Remove alternative PHP tags RFC https://wiki.php.net/rfc/remove_alternative_php_tags

2)https://fb.com/groups/2204685680/permalink/10157687999015681/