# Remove alternative PHP tags

- Thread: https://externals.io/message/77122
- Original archive: https://news-web.php.net/php.internals/77122
- Started by Nikita Popov on 2014-09-09T22:08:34+00:00
- Messages: 12
- RFC: Remove alternative PHP tags (Implemented (PHP 7.0)) — https://externals.io/rfc/remove_alternative_php_tags.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #77122 — Nikita Popov — 2014-09-09T22:08:34+00:00

URL: https://externals.io/message/77122#77122

Hi internals!

I've created a small RFC proposing the removal of the alternative PHP
opening/closing tags:

    https://wiki.php.net/rfc/remove_alternative_php_tags

It removes <% and <script language=php> and the other variations of asp and
script tags.

Nikita

---

## #77124 — Leigh — 2014-09-09T23:52:12+00:00

URL: https://externals.io/message/77122#77124 · In reply to: #77122

> Hi internals!
>
> I've created a small RFC proposing the removal of the alternative PHP
> opening/closing tags:
>
>     https://wiki.php.net/rfc/remove_alternative_php_tags
>
> It removes <% and <script language=php> and the other variations of asp and
> script tags.
>
> Nikita

My opinion is that anyone relying on these in a modern version of the
language has been upgrading things the wrong way around.

No modern PHP developer relies on these as a feature of the language,
and any PHP developer relying on these almost certainly does not need
any of the new language features.

Being future facing means dropping the chaff from the past. +1

---

## #77125 — Andrea Faulds — 2014-09-10T00:21:30+00:00

URL: https://externals.io/message/77122#77125 · In reply to: #77122

> I've created a small RFC proposing the removal of the alternative PHP
> opening/closing tags:
> 
>    https://wiki.php.net/rfc/remove_alternative_php_tags
> 
> It removes <% and <script language=php> and the other variations of asp and
> script tags.

Isn’t this a bit of a needless BC break? Not very nice on people with such codebases. It’s also worth pointing out that people might be using these to get around the XML <? issue (granted, you can disable short tags).

I’d vote for this if you wrote a convertor script to help people migrate. Otherwise I think we’re just being unfair on people who used these tags.

Actually, I’d like to see a Python 2to3-esque tool in general for PHP 7. The easier we make the migration, the more likely people will do it.

--
Andrea Faulds
http://ajf.me/

---

## #77126 — Andrea Faulds — 2014-09-10T01:32:41+00:00

URL: https://externals.io/message/77122#77126 · In reply to: #77125

> Isn’t this a bit of a needless BC break? Not very nice on people with such codebases. It’s also worth pointing out that people might be using these to get around the XML <? issue (granted, you can disable short tags).
> 
> I’d vote for this if you wrote a convertor script to help people migrate. Otherwise I think we’re just being unfair on people who used these tags.
> 
> Actually, I’d like to see a Python 2to3-esque tool in general for PHP 7. The easier we make the migration, the more likely people will do it.

Some further thoughts after discussing with Tyrael (Ferenc) on IRC.

I initially thought that I’m not really against removing them really, but I think we should have a script to convert them first. Because someone, somewhere, is gonna need it.

But then I’ve thought more about it. I’m usually OK with certain BC breaks, I just don’t like this specific one. It doesn’t affect me, but, well, I don’t see the point. It doesn’t really help language consistency or anything, (OK, sure, only two sets of delimeters now, but it’s not a big deal like some other things are), and you’ll force people to update every file in their codebase if they’re affected, assuming people who use alternative tags use them everywhere. There’s also a security issue here. If someone uses PHP 7 with a codebase that has these alternative tags, your code is now visible to users instead of the output, which might include configuration details like database passwords or password hash salts. It’s also possible that people won’t notice this is happening if they only used these alternative tags in a few obscure places.

I wonder if, really, we might be better off keeping them around and just outputting E_DEPRECATED. If we do get rid of them in 7, we should have 5.7 deprecate them.
--
Andrea Faulds
http://ajf.me/

---

## #77136 — Kalle Sommer Nielsen — 2014-09-10T09:33:15+00:00

URL: https://externals.io/message/77122#77136 · In reply to: #77122

Hi Nikita

2014-09-10 0:08 GMT+02:00 Nikita Popov <nikita.ppv@gmail.com>:
> Hi internals!
>
> I've created a small RFC proposing the removal of the alternative PHP
> opening/closing tags:
>
>     https://wiki.php.net/rfc/remove_alternative_php_tags

Great RFC, +1. No need to defend these old nordic legacy features,
afair <script> was mainly added for FrontPage back in the day, and
getting rid of asp_tags also mean we have one less ini setting
affecting the language syntax which is only great.


-- 
regards,

Kalle Sommer Nielsen
kalle@php.net

---

## #77153 — Kris Craig — 2014-09-11T22:24:21+00:00

URL: https://externals.io/message/77122#77153 · In reply to: #77126

>
> 
>
> > […]
> such codebases. It’s also worth pointing out that people might be using
> these to get around the XML <? issue (granted, you can disable short tags).
> > […]
> migrate. Otherwise I think we’re just being unfair on people who used these
> tags.
> > […]
> The easier we make the migration, the more likely people will do it.
>
> Some further thoughts after discussing with Tyrael (Ferenc) on IRC.
>
> I initially thought that I’m not really against removing them really, but
> I think we should have a script to convert them first. Because someone,
> somewhere, is gonna need it.
>
> But then I’ve thought more about it. I’m usually OK with certain BC
> breaks, I just don’t like this specific one. It doesn’t affect me, but,
> well, I don’t see the point. It doesn’t really help language consistency or
> anything, (OK, sure, only two sets of delimeters now, but it’s not a big
> deal like some other things are), and you’ll force people to update every
> file in their codebase if they’re affected, assuming people who use
> alternative tags use them everywhere. There’s also a security issue here.
> If someone uses PHP 7 with a codebase that has these alternative tags, your
> code is now visible to users instead of the output, which might include
> configuration details like database passwords or password hash salts. It’s
> also possible that people won’t notice this is happening if they only used
> these alternative tags in a few obscure places.
>
> I wonder if, really, we might be better off keeping them around and just
> outputting E_DEPRECATED. If we do get rid of them in 7, we should have 5.7
> deprecate them.
> --
> Andrea Faulds
> http://ajf.me/
>
>
>
>
>
> --
> 
> 
>
>
I think Andrea raises a valid point about BC.  I agree that those old tags
should go, but I'd suggest we target that removal for PHP 7 and just add a
deprecated flag on 5.x.

--Kris

---

## #77154 — Christoph Becker — 2014-09-11T22:54:02+00:00

URL: https://externals.io/message/77122#77154 · In reply to: #77122

Nikita Popov wrote:

> I've created a small RFC proposing the removal of the alternative PHP
> opening/closing tags:
> 
>     https://wiki.php.net/rfc/remove_alternative_php_tags
> 
> It removes <% and <script language=php> and the other variations of asp and
> script tags.

The RFC states:

| The alternative PHP tags have never gained any significant degree of
| usage. Their usage has been discouraged since forever.

Unfortunately, it seems that the PHP manual doesn't mention that all
these PHP tags are discouraged.
<http://php.net/manual/en/language.basic-syntax.phpmode.php> only mentions:

| As such, while some people find short tags and ASP style tags
| convenient, they are less portable, and generally not recommended.

I wonder if there are any faithful stats regarding the usage of the
alternative PHP tags.  I have never seen them in use (I have not even
been aware of the <script ...> tags), but that doesn't mean much.

-- 
Christoph M. Becker

---

## #77158 — Ferenc Kovacs — 2014-09-12T08:54:11+00:00

URL: https://externals.io/message/77122#77158 · In reply to: #77153

>
>
> I think Andrea raises a valid point about BC.  I agree that those old tags
> should go, but I'd suggest we target that removal for PHP 7 and just add a
> deprecated flag on 5.x.
>

nobody suggested removing them in 5.x, and while I agree that adding a
deprecated notice before the removal would be a good thing, but currently
there is no 5.7, and when we discussed it back when merging phpng to
master, it seemed that many people felt that it shouldn't be one before the
release of PHP7, so I'm not sure how could someone incorporate this idea
into the rfc.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

---

## #77159 — Rowan Collins — 2014-09-12T10:35:28+00:00

URL: https://externals.io/message/77122#77159

Michael Kliewe wrote (on 12/09/2014):
> If you check Github you will see round about 10.000 code results, but 
> most of them are tests (.phpt), example files, duplicate results, and 
> maybe <100 projects that really use them, and I would guess >90% of 
> these projects are rarely used and very old.
> https://github.com/search?p=1&q=%22%3Cscript+language%3Dphp%3E%22&ref=searchresults&type=Code 


This file made me chuckle: modern PHP tags to contain the doc block, 
then dropping into <script> tags for the actual code:

https://github.com/linagora/OBM/blob/next/ui/php/obm.php

More seriously, that's an example of a project which appears to be 
currently maintained, relying on these tags throughout. Not clear if 
it's tested against the latest PHP, but no obvious indication that it's not.

I'm in two minds on this one - removing cruft like this certainly makes 
the language feel more modern and maintained, but whether it's worth 
breaking the BC on this just for the sake of it, I'm not sure...
-- 
Rowan Collins
[IMSoP]

---

## #77162 — Nikita Popov — 2014-09-12T18:08:42+00:00

URL: https://externals.io/message/77122#77162 · In reply to: #77126

> I initially thought that I’m not really against removing them really, but
> I think we should have a script to convert them first. Because someone,
> somewhere, is gonna need it.
>

I have added a small script for porting prehistoric tags, see
https://wiki.php.net/rfc/remove_alternative_php_tags#porting_tool

But then I’ve thought more about it. I’m usually OK with certain BC breaks,
> I just don’t like this specific one. It doesn’t affect me, but, well, I
> don’t see the point. It doesn’t really help language consistency or
> anything, (OK, sure, only two sets of delimeters now, but it’s not a big
> deal like some other things are), and you’ll force people to update every
> file in their codebase if they’re affected, assuming people who use
> alternative tags use them everywhere.


In the context of a recent discussion on this list about the nature of
different BC break, this is the very best BC break that is possible. It is
trivial to detect statically and it is trivial to fix statically. Nobody
needs to "update every file in their codebase" manually.


> There’s also a security issue here. If someone uses PHP 7 with a codebase
> that has these alternative tags, your code is now visible to users instead
> of the output, which might include configuration details like database
> passwords or password hash salts. It’s also possible that people won’t
> notice this is happening if they only used these alternative tags in a few
> obscure places.
>

I am amenable to adding the asp_tags option to the
http://lxr.php.net/xref/PHP_TRUNK/main/main.c#2339 list, which will trigger
a fatal error on startup if it is enabled - that should make sure that
anyone using those is aware of the problem (we can also add it to the
deprecated list in 5.7, should we have such a release). Doesn't apply to
<script> of course.

Anyway, to me this seems like a no-brainer. Given the nature of the change
(trivial to detect + fix) this is a lot safer than pretty much all the
other BC breaks we've been talking about (like minor changes to integer
semantics). If we can't do this change, then I don't think there is
anything we *can* change.

Nikita

---

## #77163 — Andrea Faulds — 2014-09-12T18:41:30+00:00

URL: https://externals.io/message/77122#77163 · In reply to: #77162

> I have added a small script for porting prehistoric tags, see https://wiki.php.net/rfc/remove_alternative_php_tags#porting_tool

That’s great! To clarify: This only works on 5.x where asp_tags is available, yes?

> I am amenable to adding the asp_tags option to the http://lxr.php.net/xref/PHP_TRUNK/main/main.c#2339 list, which will trigger a fatal error on startup if it is enabled - that should make sure that anyone using those is aware of the problem (we can also add it to the deprecated list in 5.7, should we have such a release). Doesn't apply to <script> of course.

That’d partly solve the problem.

Perhaps we could make the lexer continue to lex <script> but throw an E_COMPILE_ERROR? Then I’d be happy.
--
Andrea Faulds
http://ajf.me/

---

## #77550 — Nikita Popov — 2014-09-23T17:25:16+00:00

URL: https://externals.io/message/77122#77550 · In reply to: #77122

>
> Hi internals!
>
> I've created a small RFC proposing the removal of the alternative PHP
> opening/closing tags:
>
>     https://wiki.php.net/rfc/remove_alternative_php_tags
>
> It removes <% and <script language=php> and the other variations of asp
> and script tags.
>

As a heads up, I'll start voting on this RFC tomorrow. Since the original
submission the following changes have been made:

 * Addition of a script porting legacy tags to normal PHP tags.
 * Throwing a core error when trying to enable asp_tags. (Same as what we
do for many other removed ini options.)

Nikita
