mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
Split out string stuff.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@337356 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
9b0502b2dd
commit
8073d96d46
2 changed files with 103 additions and 0 deletions
|
@ -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;
|
||||
|
|
102
appendices/migration70/incompatible/strings.xml
Normal file
102
appendices/migration70/incompatible/strings.xml
Normal file
|
@ -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
|
||||
-->
|
Loading…
Reference in a new issue