# Is it true that short_open_tag is deprecated in PHP 6?

- Thread: https://externals.io/message/43676
- Original archive: https://news-web.php.net/php.internals/43676
- Started by Glen on 2009-04-13T14:58:05+00:00
- Messages: 44
- Page 1 of 2: messages 1 to 25 (25 per page, add `?page=N` to the URL)
- Next page: https://externals.io/message/43676.md?page=2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #43676 — Glen — 2009-04-13T14:58:05+00:00

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

- http://www.slideshare.net/thinkphp/php-53-and-php-6-a-look-ahead
- http://wiki.claroline.net/index.php/Coding_Rules

If it's not, then what are your thoughts on using ASP/JSP-style tags
(<%), and perhaps making them the recommended option?

I've just read through an old (and rather long) thread* regarding
short_open_tag, and no one mentioned this as an option.

<%= $article->title; %>

It's short, and it doesn't conflict with XML.

Glen.

* http://www.mail-archive.com/php-dev@lists.php.net/msg43002.html

---

## #43677 — Jeremy — 2009-04-13T17:15:33+00:00

URL: https://externals.io/message/43676#43677 · In reply to: #43676

Glen wrote:
> 
> It's short, and it doesn't conflict with XML.
> 

I have to say, I don't understand all the hate on short_open_tag.  So 
what if it "conflicts" with XML?  PHP is not XML.  If you use an XML 
construct in your PHP, escape it.  PHP can generate a lot of other 
languages, too -- should every construct from these languages be 
forbidden in PHP as well?

Jeremy

---

## #43679 — Kalle Sommer Nielsen — 2009-04-13T18:24:02+00:00

URL: https://externals.io/message/43676#43679 · In reply to: #43677

2009/4/13 Jeremy <jeremy@pinacol.com>:
> Glen wrote:
> > […]
>
> I have to say, I don't understand all the hate on short_open_tag.  So what
> if it "conflicts" with XML?  PHP is not XML.  If you use an XML construct in
> your PHP, escape it.  PHP can generate a lot of other languages, too --
> should every construct from these languages be forbidden in PHP as well?

Thats because with short_open_tags on, you need to use:
<?php echo('<?xml ... ?>'); ?>

to print the XML declaring, with short open tags, the xml part is
considered a piece of code, which causes a syntax error

>
> Jeremy
>
> --
> 
> 
>
>



-- 
Kalle Sommer Nielsen
kalle@php.net

---

## #43680 — James Logsdon — 2009-04-13T18:45:18+00:00

URL: https://externals.io/message/43676#43680 · In reply to: #43679

I think that's what he meant by "escape it". I haven't used short_open_tags
myself much, but as I've been exploring templating options I like it for
outputting variables.
James Logsdon




> 2009/4/13 Jeremy <jeremy@pinacol.com>:
> > […]
> what
> > […]
> in
> > […]
>
> Thats because with short_open_tags on, you need to use:
> <?php echo('<?xml ... ?>'); ?>
>
> to print the XML declaring, with short open tags, the xml part is
> considered a piece of code, which causes a syntax error
>
> > […]
>
>
>
> --
> Kalle Sommer Nielsen
> kalle@php.net

---

## #43681 — Glen — 2009-04-13T19:10:08+00:00

URL: https://externals.io/message/43676#43681 · In reply to: #43677

It was not my intention to initiate a massive debate regarding the use
of short_open_tag.

I posted for two reasons:

1. To ask if short_open_tag has been deprecated in PHP 6.
2. To suggest asp_tags as the recommended option for templating in PHP
(to keep both crowds* happy).

* The crowd *for* the use of short_open_tag (I don't believe that they
are in favour of this tag because of the particular characters used, but
rather because of its shortness), and the crowd *against* its use
(believing that, since PHP's primary use is for embedding code within
HTML documents, it should respect the use of other processing instructions).

Glen.

Jeremy wrote:
> Glen wrote:
> > […]
>
> I have to say, I don't understand all the hate on short_open_tag.  So
> what if it "conflicts" with XML?  PHP is not XML.  If you use an XML
> construct in your PHP, escape it.  PHP can generate a lot of other
> languages, too -- should every construct from these languages be
> forbidden in PHP as well?
>
> Jeremy

---

## #43682 — Stanislav Malyshev — 2009-04-13T20:06:20+00:00

URL: https://externals.io/message/43676#43682 · In reply to: #43679

Hi!

> Thats because with short_open_tags on, you need to use:
> <?php echo('<?xml ... ?>'); ?>

It's a pretty small use case (that's a problem only if you have xml 
documents which has to have php code which has to be inlined) and as you 
see, can be easily handled. I think that should not make whole very 
useful syntax deprecated.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #43683 — Mike Panchenko — 2009-04-13T20:19:32+00:00

URL: https://externals.io/message/43676#43683 · In reply to: #43682

> It's a pretty small use case (that's a problem only if you have xml
> documents which has to have php code which has to be inlined) and as you
> see, can be easily handled. I think that should not make whole very useful
> syntax deprecated.
>

+1

One of the reason's for PHP's success IMO is the ease of creating templates
with it. Forcing everyone to write <?php echo $var ?> every time just just
so that you don't have to write <?php echo '<?...' once is not a fair trade
off. My $.02.

Mike.

---

## #43685 — Evert | Filemobile — 2009-04-13T21:34:15+00:00

URL: https://externals.io/message/43676#43685 · In reply to: #43682

> Hi!
>
> > […]
>
> It's a pretty small use case (that's a problem only if you have xml  
> documents which has to have php code which has to be inlined) and as  
> you see, can be easily handled. I think that should not make whole  
> very useful syntax deprecated.

I think the parser should look ahead and check for something like :

/<?(php|[\w])

(either <?php or <? + linebreaks/whitespace).

Evert

---

## #43687 — Philip Olson — 2009-04-13T22:37:48+00:00

URL: https://externals.io/message/43676#43687 · In reply to: #43682

Today this topic may be the cloudiest and most heated in all of PHP.  
Here's the factual history of our poor little short_open_tag directive:

------------------------------------------------
php.ini values : short_open_tag
------------------------------------------------

PHP 4, 5_0
  * Default behaviour   : on
  * php.ini-dist        : on
  * php.ini-recommended : on

PHP 5_1, 5_2:
  * Default behaviour   : on
  * php.ini-dist        : on
  * php.ini-recommended : off

PHP 5_3:
  * Default behaviour   : on
  * php.ini-development : off
  * php.ini-production  : off

------------------------------------------------
php.ini descriptions : short_open_tag
------------------------------------------------

In 5_2 our reason for discouraging it is:

; - short_open_tag = Off           [Portability]
;     Using short tags is discouraged when developing code meant for  
redistribution
;     since short tags may not be supported on the target server.
; Allow the <? tag. Otherwise, only <?php and <script> tags are  
recognized.
; NOTE: Using short tags should be avoided when developing  
applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.

In 5_3 it's:

; This directive determines whether or not PHP will recognize code  
between
; <? and ?> tags as PHP source which should be processed as such. It's  
been
; recommended for several years that you not use the short tag "short  
cut" and
; instead to use the full <?php and ?> tag combination. With the wide  
spread use
; of XML and use of these tags by other languages, the server can  
become easily
; confused and end up parsing the wrong code in the wrong context. But  
because
; this short cut has been a feature for such a long time, it's  
currently still
; supported for backwards compatibility, but we recommend you don't  
use them.

------------------------------------------------

This history strongly suggests PHP is hoping and subtly forcing the  
world to stop using this directive, and although it's not deprecated  
the wording and treatment makes it feel it could be any day now. This  
situation must be clarified before 5_3 is released, and will likely  
require our BDFL to do it.

In related news, what came of this RFC? It still says "Under  
Discussion":

   - http://wiki.php.net/rfc/shortags

Regards,
Philip

---

## #43688 — Kenan Sulayman — 2009-04-13T22:48:29+00:00

URL: https://externals.io/message/43676#43688 · In reply to: #43687

Hey Guys,

Whenever I start an XHTML document, I do escape it this way:

<<?="?"?>xml version="1.0" encoding="utf-8"?>

Where the <? part will be the output by PHP.

<?="?"?> equals <? print "?" ?> equals <?php print "?" ?>

So, please do not deprecate it - because it's important for me :$

Thanks,
(c) Kenan Sulayman
Freelance Designer and Programmer

Life's Live Poetry



2009/4/14 Philip Olson <philip@roshambo.org>

>
> Today this topic may be the cloudiest and most heated in all of PHP. Here's
> the factual history of our poor little short_open_tag directive:
>
> ------------------------------------------------
> php.ini values : short_open_tag
> ------------------------------------------------
>
> PHP 4, 5_0
>  * Default behaviour   : on
>  * php.ini-dist        : on
>  * php.ini-recommended : on
>
> PHP 5_1, 5_2:
>  * Default behaviour   : on
>  * php.ini-dist        : on
>  * php.ini-recommended : off
>
> PHP 5_3:
>  * Default behaviour   : on
>  * php.ini-development : off
>  * php.ini-production  : off
>
> ------------------------------------------------
> php.ini descriptions : short_open_tag
> ------------------------------------------------
>
> In 5_2 our reason for discouraging it is:
>
> ; - short_open_tag = Off           [Portability]
> ;     Using short tags is discouraged when developing code meant for
> redistribution
> ;     since short tags may not be supported on the target server.
> ; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
> ; NOTE: Using short tags should be avoided when developing applications or
> ; libraries that are meant for redistribution, or deployment on PHP
> ; servers which are not under your control, because short tags may not
> ; be supported on the target server. For portable, redistributable code,
> ; be sure not to use short tags.
>
> In 5_3 it's:
>
> ; This directive determines whether or not PHP will recognize code between
> ; <? and ?> tags as PHP source which should be processed as such. It's been
> ; recommended for several years that you not use the short tag "short cut"
> and
> ; instead to use the full <?php and ?> tag combination. With the wide
> spread use
> ; of XML and use of these tags by other languages, the server can become
> easily
> ; confused and end up parsing the wrong code in the wrong context. But
> because
> ; this short cut has been a feature for such a long time, it's currently
> still
> ; supported for backwards compatibility, but we recommend you don't use
> them.
>
> ------------------------------------------------
>
> This history strongly suggests PHP is hoping and subtly forcing the world
> to stop using this directive, and although it's not deprecated the wording
> and treatment makes it feel it could be any day now. This situation must be
> clarified before 5_3 is released, and will likely require our BDFL to do it.
>
> In related news, what came of this RFC? It still says "Under Discussion":
>
>  - http://wiki.php.net/rfc/shortags
>
> Regards,
> Philip

---

## #43689 — Stan Vassilev | FM — 2009-04-14T06:25:13+00:00

URL: https://externals.io/message/43676#43689 · In reply to: #43688

Hi,

A vote in support of short tags, although last time I checked they were not 
removed in PHP6 (and I hate to see this brought up once more).
On top of that, the supposed XML conflict argument is not fully thought 
through, since full PHP tags are not XML compliant either:

<?php echo "?>"; ?>

In the above example, XML parsers would do this:

Processing directive: <?php echo "?>
Text node: "; ?
Parse error: >

As you see, it's a much simpler world when we realize PHP was never supposed 
to be XML in the first place. However it was supposed to be a preprocessing 
templating engine, and so we need to keep it optimized for that.

Regards,
Stan Vassilev

---

## #43690 — Rasmus Lerdorf — 2009-04-14T07:54:53+00:00

URL: https://externals.io/message/43676#43690 · In reply to: #43689

Stan Vassilev | FM wrote:
> Hi,
> 
> A vote in support of short tags, although last time I checked they were
> not removed in PHP6 (and I hate to see this brought up once more).
> On top of that, the supposed XML conflict argument is not fully thought
> through, since full PHP tags are not XML compliant either:
> 
> <?php echo "?>"; ?>
> 
> In the above example, XML parsers would do this:
> 
> Processing directive: <?php echo "?>
> Text node: "; ?
> Parse error: >
> 
> As you see, it's a much simpler world when we realize PHP was never
> supposed to be XML in the first place. However it was supposed to be a
> preprocessing templating engine, and so we need to keep it optimized for
> that.

Which is one of the reasons we decided not to remove them in PHP 6.

-Rasmus

---

## #43692 — Glen — 2009-04-14T11:41:24+00:00

URL: https://externals.io/message/43676#43692 · In reply to: #43683

I'm not suggesting anyone be forced to do anything.

But:

<?xml version="1.0" encoding="UTF-8" ?>
...
<%= $this->that; %>

Looks neater than:

<?= '<?xml version="1.0" encoding="UTF-8" ?>'; ?>
...
<?= $this->that; ?>

Hence my suggestion.

Glen.

Mike Panchenko wrote:
> 
>
>   
> > […]
>
> +1
>
> One of the reason's for PHP's success IMO is the ease of creating templates
> with it. Forcing everyone to write <?php echo $var ?> every time just just
> so that you don't have to write <?php echo '<?...' once is not a fair trade
> off. My $.02.
>
> Mike.

---

## #43693 — Glen — 2009-04-14T11:47:22+00:00

URL: https://externals.io/message/43676#43693 · In reply to: #43685

Right, but at the moment something like:

<?$this->that;?>

... works. i.e. no whitespace after the opening tag.

Changing this would most likely break a fair amount of code.

Glen.

Evert | Filemobile wrote:
>
> 
>
> > […]
>
> I think the parser should look ahead and check for something like :
>
> /<?(php|[\w])
>
> (either <?php or <? + linebreaks/whitespace).
>
> Evert

---

## #43694 — Jani Taskinen — 2009-04-14T11:56:48+00:00

URL: https://externals.io/message/43676#43694 · In reply to: #43693

PLEASE, let the dead horse be!

--Jani


Glen wrote:
> Right, but at the moment something like:
> 
> <?$this->that;?>
> 
> .. works. i.e. no whitespace after the opening tag.
> 
> Changing this would most likely break a fair amount of code.
> 
> Glen.
> 
> Evert | Filemobile wrote:
> > […]

---

## #43695 — Glen — 2009-04-14T12:05:06+00:00

URL: https://externals.io/message/43676#43695 · In reply to: #43687

Thanks for the information, Philip.

I hereby summon the BDFL ... erm, no pressure. :-)

I really think ASP/JSP tags could be the answer.

Glen.

Philip Olson wrote:
>
> Today this topic may be the cloudiest and most heated in all of PHP.
> Here's the factual history of our poor little short_open_tag directive:
>
> ------------------------------------------------
> php.ini values : short_open_tag
> ------------------------------------------------
>
> PHP 4, 5_0
>  * Default behaviour   : on
>  * php.ini-dist        : on
>  * php.ini-recommended : on
>
> PHP 5_1, 5_2:
>  * Default behaviour   : on
>  * php.ini-dist        : on
>  * php.ini-recommended : off
>
> PHP 5_3:
>  * Default behaviour   : on
>  * php.ini-development : off
>  * php.ini-production  : off
>
> ------------------------------------------------
> php.ini descriptions : short_open_tag
> ------------------------------------------------
>
> In 5_2 our reason for discouraging it is:
>
> ; - short_open_tag = Off           [Portability]
> ;     Using short tags is discouraged when developing code meant for
> redistribution
> ;     since short tags may not be supported on the target server.
> ; Allow the <? tag. Otherwise, only <?php and <script> tags are
> recognized.
> ; NOTE: Using short tags should be avoided when developing
> applications or
> ; libraries that are meant for redistribution, or deployment on PHP
> ; servers which are not under your control, because short tags may not
> ; be supported on the target server. For portable, redistributable code,
> ; be sure not to use short tags.
>
> In 5_3 it's:
>
> ; This directive determines whether or not PHP will recognize code
> between
> ; <? and ?> tags as PHP source which should be processed as such. It's
> been
> ; recommended for several years that you not use the short tag "short
> cut" and
> ; instead to use the full <?php and ?> tag combination. With the wide
> spread use
> ; of XML and use of these tags by other languages, the server can
> become easily
> ; confused and end up parsing the wrong code in the wrong context. But
> because
> ; this short cut has been a feature for such a long time, it's
> currently still
> ; supported for backwards compatibility, but we recommend you don't
> use them.
>
> ------------------------------------------------
>
> This history strongly suggests PHP is hoping and subtly forcing the
> world to stop using this directive, and although it's not deprecated
> the wording and treatment makes it feel it could be any day now. This
> situation must be clarified before 5_3 is released, and will likely
> require our BDFL to do it.
>
> In related news, what came of this RFC? It still says "Under Discussion":
>
>   - http://wiki.php.net/rfc/shortags
>
> Regards,
> Philip

---

## #43696 — Glen — 2009-04-14T12:08:02+00:00

URL: https://externals.io/message/43676#43696 · In reply to: #43694

Which horse are you referring to exactly?

Jani Taskinen wrote:
> PLEASE, let the dead horse be!
>
> --Jani
>
>
> Glen wrote:
> > […]

---

## #43697 — Glen — 2009-04-14T12:17:38+00:00

URL: https://externals.io/message/43676#43697 · In reply to: #43688

Why such a complicated-looking thing (that breaks syntax-highlighting,
at least in my IDE), when you can just use:

<?= '<?xml version="1.0" encoding="UTF-8" ?>'; ?>

Or turn short_open_tag off (and asp_tags on), and use:

<?xml version="1.0" encoding="UTF-8" ?>
...
<%= $this->that; %>

Glen.

Kenan Sulayman wrote:
> Hey Guys,
>
> Whenever I start an XHTML document, I do escape it this way:
>
> <<?="?"?>xml version="1.0" encoding="utf-8"?>
>
> Where the <? part will be the output by PHP.
>
> <?="?"?> equals <? print "?" ?> equals <?php print "?" ?>
>
> So, please do not deprecate it - because it's important for me :$
>
> Thanks,
> (c) Kenan Sulayman
> Freelance Designer and Programmer
>
> Life's Live Poetry
>
>
>
> 2009/4/14 Philip Olson <philip@roshambo.org>
>
>   
> > […]

---

## #43698 — Glen — 2009-04-14T12:26:15+00:00

URL: https://externals.io/message/43676#43698 · In reply to: #43689

I didn't say PHP tags were valid XML. I said short_open_tag conflicts
with <?xml and other PIs.

<% is not valid XML either, but it doesn't conflict with processing
instructions.

Glen.

Stan Vassilev | FM wrote:
> Hi,
>
> A vote in support of short tags, although last time I checked they
> were not removed in PHP6 (and I hate to see this brought up once more).
> On top of that, the supposed XML conflict argument is not fully
> thought through, since full PHP tags are not XML compliant either:
>
> <?php echo "?>"; ?>
>
> In the above example, XML parsers would do this:
>
> Processing directive: <?php echo "?>
> Text node: "; ?
> Parse error: >
>
> As you see, it's a much simpler world when we realize PHP was never
> supposed to be XML in the first place. However it was supposed to be a
> preprocessing templating engine, and so we need to keep it optimized
> for that.
>
> Regards,
> Stan Vassilev

---

## #43699 — Mikko Koppanen — 2009-04-14T12:34:08+00:00

URL: https://externals.io/message/43676#43699 · In reply to: #43698

> I didn't say PHP tags were valid XML. I said short_open_tag conflicts
> with <?xml and other PIs.
>
> <% is not valid XML either, but it doesn't conflict with processing
> instructions.
>
> Glen.



Hello Glen,

posting to mailing-lists is not a speed race so think about your answer
before sending it. There should be no need to send four emails in a row as
you can easily answer multiple persons / arguments in a single post. This
discussion belongs to internals list anymore, so please move it to
php-general mailing list.

CCing the correct list in this mail.

-- 
Mikko Koppanen

---

## #43701 — Arvids Godjuks — 2009-04-14T15:11:10+00:00

URL: https://externals.io/message/43676#43701 · In reply to: #43695

Hello everyone.
I've been writing <?php echo get('something')?> for some time now at the
last project and it really sucks. I understand reason on depricating
short_open_tag and I agree. But I have a proposal witch can ease templating.

Remove short open tag, but leave <?=get('blah')?>. Bacicaly PHP parser
should look for <?php or <?=, single <? is not allowed. That way:
1). short_open_tag is gone for good as an option in .ini.
2). Making templates doesn't suck
3). Backwards compability with old templates is preserved (old templates
with <?= work fine).
4). <? in code is broken as you want it to be and makes coders fix it with
<?php

Everyone is happy, XML and others are safe.

Yes, it's really irritating to write <?php echo every time!

---

## #43702 — david.zuelke@bitextender.com — 2009-04-14T15:16:13+00:00

URL: https://externals.io/message/43676#43702 · In reply to: #43701

As Jani put it:

> PLEASE, let the dead horse be!

- David




> Hello everyone.
> I've been writing <?php echo get('something')?> for some time now at  
> the
> last project and it really sucks. I understand reason on depricating
> short_open_tag and I agree. But I have a proposal witch can ease  
> templating.
>
> Remove short open tag, but leave <?=get('blah')?>. Bacicaly PHP parser
> should look for <?php or <?=, single <? is not allowed. That way:
> 1). short_open_tag is gone for good as an option in .ini.
> 2). Making templates doesn't suck
> 3). Backwards compability with old templates is preserved (old  
> templates
> with <?= work fine).
> 4). <? in code is broken as you want it to be and makes coders fix  
> it with
> <?php
>
> Everyone is happy, XML and others are safe.
>
> Yes, it's really irritating to write <?php echo every time!

---

## #43703 — Mark Krenz — 2009-04-14T15:51:45+00:00

URL: https://externals.io/message/43676#43703 · In reply to: #43701

On Tue, Apr 14, 2009 at 03:11:10PM GMT, Arvids Godjuks [arvids.godjuks@gmail.com] said the following:
> 
> Yes, it's really irritating to write <?php echo every time!

 Until you get used to it.  I started with PHP back in 98 and remember
a bit of resistance in learning the <?php thing, but I knew it was for
the best and now I'm not regretting it.  For me, its just normal now.

-- 
Mark S. Krenz
IT Director
Suso Technology Services, Inc.
http://suso.org/

---

## #43704 — Stanislav Malyshev — 2009-04-14T17:55:57+00:00

URL: https://externals.io/message/43676#43704 · In reply to: #43702

Hi!

> > […]

Apparently, this horse is not as dead as some would like it to be :)
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #43705 — Philip Olson — 2009-04-14T18:06:42+00:00

URL: https://externals.io/message/43676#43705 · In reply to: #43704

> > […]
>
> Apparently, this horse is not as dead as some would like it to be :)

The horse is not dead or if so then no proper burial service was  
given. People are still waiting for the invitations and wanting to  
hear the eulogy.

So, instead I'll make the following assumptions and engrave them into  
this topics tombstone:

  - short_open_tag is fully alive
  - short_open_tag is PHP_INI_SYSTEM|PHP_INI_PERDIR
  - all distributed php.ini files disable it (5.3+)
  - the default will be enabled, forever, unless #5 is used
  - --disable-short-tags will exist, forever
  - no new alternative syntax will be implemented, ever

That's the situation people should understand and since this horse is  
considered dead I will:

  - update php.ini ini descriptions to reflect this
  - update documentation to reflect this
  - mark http://wiki.php.net/rfc/shortags as declined
  - point to the declined rfc when people suggest these alternatives

All discussion is over unless a human knows the above synopsis is  
false, because CVS has spoken. RIP.

Regards,
Philip

---

Next page: https://externals.io/message/43676.md?page=2
