[PHP-DEV] Deprecate short_open_tag ini directive?

  104662
March 11, 2019 20:06 george.banyard@gmail.com ("G. P. B.")
Hello internals,

I'm currently going through the PHP doc to remove mentions of PHP 4
and stumbled upon the short_open_tag ini directive [1] which only affects
the availability of `https://secure.php.net/manual/en/ini.core.php#ini.short-open-tag
  104665
March 12, 2019 09:51 rowan.collins@gmail.com (Rowan Collins)
On Mon, 11 Mar 2019 at 20:06, G. P. B. banyard@gmail.com> wrote:

> From my understanding, the ` so maybe we should deprecate PHP's short tag altogether? >
I think when that's been proposed in the past, people have said they like it for use in simple templates, often along with the "alternative control structures", e.g.: quantity > 1 ): ?>

description; ?>

I couldn't find any discussions for a few years, though, so it's possible opinions have changed. Regards, -- Rowan Collins [IMSoP]
  104666
March 12, 2019 10:11 peterkokot@gmail.com (Peter Kokot)
Hello,
On Tue, 12 Mar 2019 at 10:51, Rowan Collins collins@gmail.com> wrote:
> > On Mon, 11 Mar 2019 at 20:06, G. P. B. banyard@gmail.com> wrote: > > > From my understanding, the ` > so maybe we should deprecate PHP's short tag altogether? > > > > > I think when that's been proposed in the past, people have said they like > it for use in simple templates, often along with the "alternative control > structures", e.g.: > > > quantity > 1 ): ?>

description; ?>

endif; ?> > > > I couldn't find any discussions for a few years, though, so it's possible > opinions have changed. > > Regards, > -- > Rowan Collins > [IMSoP]
PHP based template engines today most likely use only
  104667
March 12, 2019 10:39 rowan.collins@gmail.com (Rowan Collins)
On Tue, 12 Mar 2019 at 10:12, Peter Kokot <peterkokot@gmail.com> wrote:

> > PHP based template engines today most likely use only because of this topic today exactly. Possibility of being deprecated > :) I think the short opening tags are good to go so things are more > simple. >
A quick search of the list archives showed the opposite: reassurances that short open tags are *not* deprecated, and vocal support for keeping them.
> A side question is there any plan to move the idea of removing opening > moved out of the template engines world and left that task to more > dedicated so called compiled or parsed template engines (such as Twig > or Blade), so maybe something to think about as well. >
I think that's a different discussion - and also one that's happened a few times in the past. I think the general conclusion was that the gain isn't big enough to bother changing every tool that works with PHP. Regards, -- Rowan Collins [IMSoP]
  104668
March 12, 2019 11:15 drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=)
Hi,

I guess that `short_open_tag` ini settings can be deprecated/removed.
But that would mean that short open tags will be always available, not that
it will be removed.

Regards,
Alex

On Tue, Mar 12, 2019 at 12:39 PM Rowan Collins collins@gmail.com>
wrote:

> On Tue, 12 Mar 2019 at 10:12, Peter Kokot <peterkokot@gmail.com> wrote: > > > > > PHP based template engines today most likely use only > because of this topic today exactly. Possibility of being deprecated > > :) I think the short opening tags are good to go so things are more > > simple. > > > > > A quick search of the list archives showed the opposite: reassurances that > short open tags are *not* deprecated, and vocal support for keeping them. > > > > > A side question is there any plan to move the idea of removing opening > > > moved out of the template engines world and left that task to more > > dedicated so called compiled or parsed template engines (such as Twig > > or Blade), so maybe something to think about as well. > > > > > I think that's a different discussion - and also one that's happened a few > times in the past. I think the general conclusion was that the gain isn't > big enough to bother changing every tool that works with PHP. > > Regards, > -- > Rowan Collins > [IMSoP] >
  104669
March 12, 2019 11:27 peterkokot@gmail.com (Peter Kokot)
On Tue, 12 Mar 2019 at 12:15, Alexandru Pătrănescu <drealecs@gmail.com> wrote:
> > Hi, > > I guess that `short_open_tag` ini settings can be deprecated/removed. > But that would mean that short open tags will be always available, not that > it will be removed. > > Regards, > Alex
Oh, the main idea is to remove the ini directive which will make the short tags by default then on? So the currently not enabled short tags will be again enabled by default? From what I understand here, probably deprecation is referring also to the short tags themselves in favour of the
  104671
March 12, 2019 13:27 george.banyard@gmail.com ("G. P. B.")
I was more going along the lines of removing short tags altogether with the
ini setting as they are not available out of the box except if you use a
special compile flag. However, I didn't know they were used with template
engines but wouldn't they just use `
    
  104672
March 12, 2019 13:43 cmbecker69@gmx.de ("Christoph M. Becker")
On 12.03.2019 at 14:27, G. P. B. wrote:

> I was more going along the lines of removing short tags altogether with the > ini setting as they are not available out of the box except if you use a > special compile flag.
To my knowledge, short_open_tag=1 *always* enables short open tags, regardless of the configure option --disable-short-tags or others. -- Christoph M. Becker
  104673
March 12, 2019 13:46 george.banyard@gmail.com ("G. P. B.")
On Tue, 12 Mar 2019 at 14:43, Christoph M. Becker <cmbecker69@gmx.de> wrote:

> On 12.03.2019 at 14:27, G. P. B. wrote: > > > I was more going along the lines of removing short tags altogether with > the > > ini setting as they are not available out of the box except if you use a > > special compile flag. > > To my knowledge, short_open_tag=1 *always* enables short open tags, > regardless of the configure option --disable-short-tags or others. > > -- > Christoph M. Becker >
I really need to get better at articulating what I mean. From what I know this is the case but when I meant out of the box I meant without using the ini configuration. So it is possible to use it if you declare the INI config. However it may clash with XML from my understanding of the doc. Best Regards George P. Banyard
  104680
March 12, 2019 15:53 rowan.collins@gmail.com (Rowan Collins)
On Tue, 12 Mar 2019 at 13:28, G. P. B. banyard@gmail.com> wrote:

> I was more going along the lines of removing short tags altogether with the > ini setting as they are not available out of the box except if you use a > special compile flag. >
I don't really follow this reasoning: if we removed every feature which wasn't enabled out of the box, we wouldn't need an INI file at all. The question has to be whether including the option to turn this on is still useful to people.
> However, I didn't know they were used with template > engines but wouldn't they just use `
No, as shown in my previous example, I've seen people use short-tags for logic, like some HTML
> I mean I don't really have any strong opinions about it. It just seems a > bit odd considering we removed ASP tags in, IIRC, PHP 7. >
ASP tags were removed because they were very rarely used, and most people probably didn't even know they existed. Short tags, in contrast, are actually *older* than the full "
  104683
March 12, 2019 16:57 johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=)
On Di, 2019-03-12 at 15:53 +0000, Rowan Collins wrote:
> On Tue, 12 Mar 2019 at 13:28, G. P. B. banyard@gmail.com> > wrote: > > > > > I was more going along the lines of removing short tags altogether > > with the > > ini setting as they are not available out of the box except if you > > use a > > special compile flag. > > > > I don't really follow this reasoning: if we removed every feature > which wasn't enabled out of the box, we wouldn't need an INI file at > all.
Which would be good - as all those things make writing portable code harder.    $ echo '' | php Is a valid program, which will behave vastly different based on the ini setting. Of course for some things having a config is good (error levels arguably, extension loading, ...) but for the raw language syntax and behavior not so. johannes
  104686
March 12, 2019 22:50 peterkokot@gmail.com (Peter Kokot)
Hello,

On Tue, 12 Mar 2019 at 17:57, Johannes Schlüter <johannes@schlueters.de> wrote:
> > On Di, 2019-03-12 at 15:53 +0000, Rowan Collins wrote: > > On Tue, 12 Mar 2019 at 13:28, G. P. B. banyard@gmail.com> > > wrote: > > > > > > > > I was more going along the lines of removing short tags altogether > > > with the > > > ini setting as they are not available out of the box except if you > > > use a > > > special compile flag. > > > > > > > I don't really follow this reasoning: if we removed every feature > > which wasn't enabled out of the box, we wouldn't need an INI file at > > all. > > Which would be good - as all those things make writing portable code > harder. > > $ echo '' | php > > Is a valid program, which will behave vastly different based on the ini > setting. > > Of course for some things having a config is good (error levels > arguably, extension loading, ...) but for the raw language syntax and > behavior not so. > > johannes > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >
In reality if developer wants to write "portable" and proper PHP code, no one actually should use these short tags anymore. If they are still used somewhere as part of some legacy code, they won't work on majority of PHP installations anymore because the mostly have these turned off today in the php.ini files. So, the question here is more why supporting a feature that no one should use anymore... -- Peter Kokot
  104689
March 13, 2019 00:14 johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=)
On Di, 2019-03-12 at 23:50 +0100, Peter Kokot wrote:
>  > > Which would be good - as all those things make writing portable > > code > > harder. > > > >    $ echo '' | php > > > > Is a valid program, which will behave vastly different based on the > > ini > > setting. > > In reality if developer wants to write "portable" and proper PHP > code, no one actually should use these short tags anymore. If they > are still used somewhere as part of some legacy code, they won't work > on majority of PHP installations anymore because the mostly have > these turned off today in the php.ini files. So, the question here is > more why supporting a feature that no one should use anymore...
the point is: The program I have shown is valid in both modes. One version is obviously stupid (referring to the constant 'xml' and not doing anything further) but still valid. Being just a developer from down the street I might not have been aware of that and delivered the program to a user who, for whatever reason, had short tags enabled and probably won't see a proper error. If they know there are workarounds ( '?>  is a portable version) but such things are a real pain. Having langage changing based on an ini setting is bad. (ze1 compatibility mode was really really fun in early PHP 5 ... not) johannes
  104752
March 15, 2019 15:56 george.banyard@gmail.com ("G. P. B.")
Just gonna do general reply instead of pointing at specific points.

But as it has been pointed out using short tags makes the code less
portable,
which IMO isn't ideal.

I personally don't tinker with INI settings withing PHP with `ini_set` as
IMHO if you
need to change them it should be done in the php.ini file.
However, I'm not sure of the behavior if someone sets this behavior within
a file/class
does this only affect this specific instance or is it globally?
Because if it is globally I can see code that writes/uses XML be affected
as pointed
out by Johannes

As it seems that there are people for and against; I suppose I could write
an RFC
for this, but would need the karma to do so.

Best regards

George P. Banyard
  104753
March 15, 2019 16:02 rowan.collins@gmail.com (Rowan Collins)
On Fri, 15 Mar 2019 at 15:56, G. P. B. banyard@gmail.com> wrote:

> However, I'm not sure of the behavior if someone sets this behavior within > a file/class > does this only affect this specific instance or is it globally? >
Not all settings can be altered with ini_set; this one is listed at http://php.net/manual/en/ini.core.php#ini.short-open-tag as PHP_INI_PERDIR, which http://php.net/manual/en/configuration.changes.modes.php describes as:
> Entry can be set in php.ini, .htaccess, httpd.conf or .user.ini (since PHP 5.3)
Regards, -- Rowan Collins [IMSoP]
  104754
March 15, 2019 16:05 george.banyard@gmail.com ("G. P. B.")
On Fri, 15 Mar 2019 at 17:03, Rowan Collins collins@gmail.com> wrote:

> On Fri, 15 Mar 2019 at 15:56, G. P. B. banyard@gmail.com> wrote: > > > However, I'm not sure of the behavior if someone sets this behavior > within > > a file/class > > does this only affect this specific instance or is it globally? > > > > Not all settings can be altered with ini_set; this one is listed at > http://php.net/manual/en/ini.core.php#ini.short-open-tag as > PHP_INI_PERDIR, > which http://php.net/manual/en/configuration.changes.modes.php describes > as: > > > Entry can be set in php.ini, .htaccess, httpd.conf or .user.ini (since > PHP 5.3) > > Regards, > -- > Rowan Collins > [IMSoP] >
Huh didn't know about this behavior, thanks for pointing it out. Best regards George P. Banyard
  104682
March 12, 2019 16:57 smalyshev@gmail.com (Stanislav Malyshev)
Hi!

> I'm currently going through the PHP doc to remove mentions of PHP 4 > and stumbled upon the short_open_tag ini directive [1] which only affects > the availability of ` From my understanding, the ` so maybe we should deprecate PHP's short tag altogether?
Why? What would it improve for people that are using it? For people that aren't, it obviously won't change anything. So what would be the motivation for this change? -- Stas Malyshev smalyshev@gmail.com
  104763
March 16, 2019 02:44 xellisx@gmail.com (Kenneth Ellis McCall)
G. P. B. wrote:
> currently going through the PHP doc to remove mentions of PHP 4 > and stumbled upon the short_open_tag ini directive [1] which only affects > the availability of ` From my understanding, the ` so maybe we should deprecate PHP's short tag altogether?
I would like to see that. "Question mark equals what?". If you want to go further, dropping the PHP tag altogether would be nice, since it would prevent context switching between PHP/HTML/JS/whatever. That would force Wordpress to update their whole code base. >:{)>
  104766
March 16, 2019 02:56 morganbreden@gmail.com (Morgan Breden)
>If you want to go further, dropping the PHP tag altogether would be nice, since it would prevent context switching between PHP/HTML/JS/whatever.
>That would force Wordpress to update their whole code base. >:{)>
I wholeheartedly support this initiative but I do not see it going through without a lot of resistance. Using PHP itself as a templating engine is part of what makes it so "newbie friendly".
  104768
March 16, 2019 03:19 peterkokot@gmail.com (Peter Kokot)
Hello,
On Sat, 16 Mar 2019 at 03:57, Morgan Breden <morganbreden@gmail.com> wrote:
> > >If you want to go further, dropping the PHP tag altogether would be nice, > since it would prevent context switching between PHP/HTML/JS/whatever. > >That would force Wordpress to update their whole > code base. >:{)> > > I wholeheartedly support this initiative but I do not see it going through > without a lot of resistance. Using PHP itself as a templating engine is > part of what makes it so "newbie friendly".
I think using PHP tags for templates and option to write code without opening tag might go through also. After all, text files are simple. Something on this was already being done and probably also discussed: https://wiki.php.net/rfc/nophptags On the other hand, shebangs will still be present in CLI scripts. For example: #!/usr/bin/env php -- Peter Kokot
  104767
March 16, 2019 03:05 george.banyard@gmail.com ("G. P. B.")
On Sat, 16 Mar 2019 at 03:44, Kenneth Ellis McCall <xellisx@gmail.com>
wrote:

> G. P. B. wrote: > > currently going through the PHP doc to remove mentions of PHP 4 > > and stumbled upon the short_open_tag ini directive [1] which only affects > > the availability of ` > From my understanding, the ` directive, > > so maybe we should deprecate PHP's short tag altogether? > > I would like to see that. "Question mark equals what?". > > If you want to go further, dropping the PHP tag altogether would be > nice, since it would prevent context switching between > PHP/HTML/JS/whatever. That would force Wordpress to update their whole > code base. >:{)>
As I don't know how to email I already sent a private response which basically states that the `https://secure.php.net/manual/en/ini.core.php#ini.short-open-tag (thinking of it this feature maybe could be better documented) Also I could write an RFC for the deprecation as it is controversial but as I said before I would need someone to grant me RFC karma to my PHP.net account girgias Best regards George P. Banyard