svn: /phpdoc/en/trunk/language/ basic-syntax.xml
| From: | Adam Harvey | Date: | Sun, 09 Aug 2015 01:15:42 +0000 |
| Subject: | svn: /phpdoc/en/trunk/language/ basic-syntax.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-13534@lists.php.net to get a copy of this message | ||
aharvey Sun, 09 Aug 2015 01:15:42 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=337351
Log:
Update the basic syntax documentation for the removed tags in PHP 7.
Changed paths:
U phpdoc/en/trunk/language/basic-syntax.xml
Modified: phpdoc/en/trunk/language/basic-syntax.xml
===================================================================
--- phpdoc/en/trunk/language/basic-syntax.xml 2015-08-09 01:15:38 UTC (rev 337350)
+++ phpdoc/en/trunk/language/basic-syntax.xml 2015-08-09 01:15:42 UTC (rev 337351)
@@ -5,23 +5,44 @@
<sect1 xml:id="language.basic-syntax.phptags">
<title>PHP tags</title>
<para>
- When PHP parses a file, it looks for opening and closing tags,
- which are <literal><?php</literal> and
<literal>?></literal>
- which tell PHP to start and stop interpreting the code between
- them. Parsing in this manner allows PHP to be embedded in all
- sorts of different documents, as everything outside of a pair
- of opening and closing tags is ignored by the PHP parser.
+ When PHP parses a file, it looks for opening and closing tags, which are
+ <literal><?php</literal> and <literal>?></literal> which
tell PHP to
+ start and stop interpreting the code between them. Parsing in this manner
+ allows PHP to be embedded in all sorts of different documents, as
+ everything outside of a pair of opening and closing tags is ignored by the
+ PHP parser.
</para>
<para>
- PHP also allows for short open tag <literal><?</literal>
- (which is discouraged since it is only available if enabled using the
- <link linkend="ini.short-open-tag">short_open_tag</link> &php.ini;
configuration
- file directive, or if PHP was configured with the
<option>--enable-short-tags</option>
- option).
+ PHP also allows for short open tag <literal><?</literal> (which is
+ discouraged since it is only available if enabled using the
+ <link linkend="ini.short-open-tag">short_open_tag</link> &php.ini;
+ configuration file directive, or if PHP was configured with the
+ <option>--enable-short-tags</option> option).
</para>
<para>
+ If a file is pure PHP code, it is preferable to omit the PHP closing tag
+ at the end of the file. This prevents accidental whitespace or new lines
+ being added after the PHP closing tag, which may cause unwanted effects
+ because PHP will start output buffering when there is no intention from
+ the programmer to send any output at that point in the script.
+ <informalexample>
+ <programlisting role="php">
+<![CDATA[
+<?php
+echo "Hello world";
+
+// ... more code
+
+echo "Last statement";
+
+// the script ends here with no PHP closing tag
+]]>
+ </programlisting>
+ </informalexample>
+ </para>
+ <para>
<table>
- <title>Changelogs</title>
+ &reftitle.changelog;
<tgroup cols="2">
<thead>
<row>
@@ -33,8 +54,9 @@
<row>
<entry>7.0.0</entry>
<entry>
- ASP tags <% , %> , <%= , and script tag <script
language=php>
- are removed from PHP.
+ The ASP tags <code><%</code>, <code>%></code>,
+ <code><%=</code>, and the script tag
+ <code><script language="php"></code> are removed from
PHP.
</entry>
</row>
<row>
@@ -47,27 +69,6 @@
</tgroup>
</table>
</para>
- <para>
- If a file is pure PHP code, it is preferable to omit the PHP closing tag at the
- end of the file. This prevents accidental whitespace or new lines being added after the PHP
- closing tag, which may cause unwanted effects because PHP will start output
- buffering when there is no intention from the programmer to send any output
- at that point in the script.
- <informalexample>
- <programlisting role="php">
-<![CDATA[
-<?php
-echo "Hello world";
-
-// ... more code
-
-echo "Last statement";
-
-// the script ends here with no PHP closing tag
-]]>
- </programlisting>
- </informalexample>
- </para>
</sect1>
<sect1 xml:id="language.basic-syntax.phpmode">
<title>Escaping from HTML</title>
@@ -118,14 +119,18 @@
<function>echo</function> or <function>print</function>.
</para>
<para>
- There are four different pairs of opening and closing tags
- which can be used in PHP. Two of those, <?php ?> and
- <script language="php"> </script>, are always available.
- The other two are short tags and <productname>ASP</productname>
- style tags, and can be turned on and off from the &php.ini;
- configuration file. As such, while some people find short tags
- and <productname>ASP</productname> style tags convenient, they
- are less portable, and generally not recommended.
+ In PHP 5, there are up to five different pairs of opening and closing tags
+ available in PHP, depending on how PHP is configured. Two of these,
+ <code><?php ?></code> and
+ <code><script language="php">
</script></code>, are always
+ available. There is also the short echo tag <code><?= ?></code>,
+ which is always available in PHP 5.4.0 and later.
+ </para>
+ <para>
+ The other two are short tags and <productname>ASP</productname> style
+ tags. As such, while some people find short tags and
+ <productname>ASP</productname> style tags convenient, they are less
+ portable, and generally not recommended.
<note>
<para>
Also note that if you are embedding PHP within XML or XHTML
@@ -135,6 +140,12 @@
</note>
</para>
<para>
+ PHP 7 removes support for <productname>ASP</productname> tags and
+ <code><script language="php"></code> tags. As such, we
recommend
+ only using <code><?php ?></code> and <code><?=
?></code> when
+ writing PHP code to maximise compatibility.
+ </para>
+ <para>
<example>
<title>PHP Opening and Closing Tags</title>
<programlisting role="php">
@@ -142,35 +153,37 @@
1. <?php echo 'if you want to serve PHP code in XHTML or XML documents,
use these tags'; ?>
-2. <script language="php">
+2. You can use the short echo tag to <?= 'print this string' ?>.
+ It's always enabled in PHP 5.4.0 and later, and is equivalent to
+ <?php echo 'print this string' ?>.
+
+3. <? echo 'this code is within short tags, but will only work '.
+ 'if short_open_tag is enabled'; ?>
+
+4. <script language="php">
echo 'some editors (like FrontPage) don\'t
like processing instructions within these tags';
</script>
+ This syntax is removed in PHP 7.0.0.
-3. <? echo 'this code is within short tags'; ?>
- Code within these tags <?= 'some text' ?> is a shortcut for this code <?
echo 'some text' ?>
-
-4. <% echo 'You may optionally use ASP-style tags'; %>
+5. <% echo 'You may optionally use ASP-style tags'; %>
Code within these tags <%= $variable; %> is a shortcut for this code <% echo
$variable; %>
+ Both of these syntaxes are removed in PHP 7.0.0.
]]>
</programlisting>
</example>
</para>
<para>
- While the tags seen in examples one and two are both
- always available, example one is the most commonly
- used, and recommended, of the two.
- </para>
- <para>
Short tags (example three) are only available when they are
enabled via the <link linkend="ini.short-open-tag">short_open_tag</link>
&php.ini; configuration file directive, or if PHP was configured
with the <option>--enable-short-tags</option> option.
</para>
<para>
- <productname>ASP</productname> style tags (example four) are only available when
- they are enabled via the <link linkend="ini.asp-tags">asp_tags</link>
&php.ini;
- configuration file directive.
+ <productname>ASP</productname> style tags (example five) are only
+ available when they are enabled via the
+ <link linkend="ini.asp-tags">asp_tags</link> &php.ini; configuration
file
+ directive, and have been removed in PHP 7.0.0.
</para>
<para>
<note>