svn: /phpdoc/en/trunk/appendices/migration70/ incompatible/strings.xml incompatible.xml
| From: | Adam Harvey | Date: | Sun, 09 Aug 2015 01:16:15 +0000 |
| Subject: | svn: /phpdoc/en/trunk/appendices/migration70/ incompatible/strings.xml incompatible.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-13539@lists.php.net to get a copy of this message | ||
aharvey Sun, 09 Aug 2015 01:16:15 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=337356
Log:
Split out string stuff.
Changed paths:
A phpdoc/en/trunk/appendices/migration70/incompatible/strings.xml
U phpdoc/en/trunk/appendices/migration70/incompatible.xml
Added: phpdoc/en/trunk/appendices/migration70/incompatible/strings.xml
===================================================================
--- phpdoc/en/trunk/appendices/migration70/incompatible/strings.xml (rev 0)
+++ phpdoc/en/trunk/appendices/migration70/incompatible/strings.xml 2015-08-09 01:16:15 UTC (rev
337356)
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- $Revision$ -->
+
+<sect2 xml:id="migration70.incompatible.strings">
+ <title>Changes to <type>string</type> handling</title>
+
+ <sect3 xml:id="migration70.incompatible.strings.hex">
+ <title>Hexadecimal strings are no longer considered numeric</title>
+
+ <para>
+ Strings containing hexadecimal numbers are no longer considered to be
+ numeric. For example:
+ </para>
+
+ <informalexample>
+ <programlisting role="php">
+<![CDATA[
+<?php
+var_dump("0x123" == "291");
+var_dump(is_numeric("0x123"));
+var_dump("0xe" + "0x1");
+var_dump(substr("foo", "0x1"));
+?>
+]]>
+ </programlisting>
+ &example.outputs.5;
+ <screen>
+<![CDATA[
+bool(true)
+bool(true)
+int(15)
+string(2) "oo"
+]]>
+ </screen>
+ &example.outputs.7;
+ <screen>
+<![CDATA[
+bool(false)
+bool(false)
+int(0)
+
+Notice: A non well formed numeric value encountered in /tmp/test.php on line 5
+string(3) "foo"
+]]>
+ </screen>
+ </informalexample>
+
+ <para>
+ <function>filter_var</function> can be used to check if a
+ <type>string</type> contains a hexadecimal number, and also to convert a
+ string of that type to an <type>integer</type>:
+ </para>
+
+ <informalexample>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$str = "0xffff";
+$int = filter_var($str, FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX);
+if (false === $int) {
+ throw new Exception("Invalid integer!");
+}
+var_dump($int); // int(65535)
+?>
+]]>
+ </programlisting>
+ </informalexample>
+ </sect3>
+
+ <sect3 xml:id="migration70.incompatible.strings.unicode-escapes">
+ <title><literal>\u{</literal> may cause errors</title>
+
+ <para>
+ Due to the addition of the new
+ <link linkend="migration70.new-features.unicode-codepoint-escape-syntax">Unicode
codepoint escape syntax</link>,
+ strings containing a literal <literal>\u{</literal> followed by an invalid
+ sequence will cause a fatal error. To avoid this, the leading backslash
+ should be escaped.
+ </para>
+ </sect3>
+</sect2>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:1
+sgml-indent-data:t
+indent-tabs-mode:nil
+sgml-parent-document:nil
+sgml-default-dtd-file:"~/.phpdoc/manual.ced"
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+vim600: syn=xml fen fdm=syntax fdl=2 si
+vim: et tw=78 syn=sgml
+vi: ts=1 sw=1
+-->
Modified: phpdoc/en/trunk/appendices/migration70/incompatible.xml
===================================================================
--- phpdoc/en/trunk/appendices/migration70/incompatible.xml 2015-08-09 01:16:10 UTC (rev 337355)
+++ phpdoc/en/trunk/appendices/migration70/incompatible.xml 2015-08-09 01:16:15 UTC (rev 337356)
@@ -7,6 +7,7 @@
&appendices.migration70.incompatible.variable-handling;
&appendices.migration70.incompatible.foreach;
&appendices.migration70.incompatible.integers;
+ &appendices.migration70.incompatible.strings;
&appendices.migration70.incompatible.removed-functions;
&appendices.migration70.incompatible.removed-ini-directives;
&appendices.migration70.incompatible.other;