rfc:deprecate_php_short_tags

PHP RFC: Deprecate PHP Short open tags

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)

Deprecate PHP short open tags in PHP 7.4?
Real name Yes No
ashnazg  
bishop  
bwoebi  
carusogabriel  
colinodell  
cpriest  
danack  
daverandom  
derick  
diegopires  
duncan3dc  
emir  
galvao  
gasolwu  
girgias  
guilhermeblanco  
heiglandreas  
jasny  
jbnahan  
jhdxr  
kalle  
kelunik  
kguest  
kinncj  
klaussilveira  
krakjoe  
kriscraig  
laruence  
levim  
malukenho  
marcio  
mariano  
mbeccati  
mcmic  
mike  
narf  
nikic  
ocramius  
pauloelr  
peehaa  
petk  
pmjones  
pmmaga  
pollita  
rasmus  
reywob  
rtheunissen  
salathe  
santiagolizardo  
sebastian  
sergey  
stas  
svpernova09  
thekid  
trowski  
yunosh  
Final result: 38 18
This poll has been closed.
Remove PHP short open tags in PHP 8.0?
Real name Yes No
ashnazg  
bwoebi  
carusogabriel  
colinodell  
cpriest  
danack  
daverandom  
derick  
diegopires  
duncan3dc  
emir  
galvao  
gasolwu  
girgias  
guilhermeblanco  
heiglandreas  
jasny  
jbnahan  
jhdxr  
kalle  
kelunik  
kguest  
kinncj  
klaussilveira  
krakjoe  
kriscraig  
laruence  
levim  
malukenho  
marcio  
mariano  
mbeccati  
mcmic  
mike  
narf  
nikic  
ocramius  
pauloelr  
peehaa  
petk  
pmjones  
pmmaga  
pollita  
rasmus  
reywob  
rtheunissen  
salathe  
sammyk  
santiagolizardo  
sebastian  
sergey  
stas  
svpernova09  
thekid  
trowski  
yunosh  
zeev  
Final result: 42 15
This poll has been 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

rfc/deprecate_php_short_tags.txt · Last modified: by 127.0.0.1