svn: /phpdoc/ja/trunk/language/types/ float.xml integer.xml

[email protected] (Yoshinari Takaoka)
Newsgroups php.doc.ja
Message-ID <[email protected]>
mumumu                                   Sat, 14 Mar 2020 23:15:00 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=349442

Log:
Fix #79302: Support for underscores in numbers not documented

Bug: https://bugs.php.net/79302 (Closed) Support for underscores in numbers not documented in "floating point numbers"
      
Changed paths:
    U   phpdoc/ja/trunk/language/types/float.xml
    U   phpdoc/ja/trunk/language/types/integer.xml

Modified: phpdoc/ja/trunk/language/types/float.xml
===================================================================
--- phpdoc/ja/trunk/language/types/float.xml	2020-03-14 23:03:38 UTC (rev 349441)
+++ phpdoc/ja/trunk/language/types/float.xml	2020-03-14 23:15:00 UTC (rev 349442)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 348072 Maintainer: takagi Status: ready -->
+<!-- EN-Revision: 349427 Maintainer: takagi Status: ready -->
 <!-- CREDITS: hirokawa,shimooka,mumumu -->
 <sect1 xml:id="language.types.float" xmlns:xlink="http://www.w3.org/1999/xlink">
  <title>浮動小数点数</title>
@@ -16,6 +16,7 @@
 $a = 1.234;
 $b = 1.2e3;
 $c = 7E-10;
+$d = 1_234.567; // PHP 7.4.0 以降
 ?>
 ]]>
   </programlisting>
@@ -22,14 +23,14 @@
  </informalexample>

  <para>
-  規約:
+  PHP 7.4.0 以降の規約(これより前のバージョンでは、アンダースコアは許されませんでした):
  </para>

  <informalexample>
   <programlisting>
 <![CDATA[
-LNUM          [0-9]+
-DNUM          ([0-9]*[\.]{LNUM}) | ({LNUM}[\.][0-9]*)
+LNUM          [0-9]+(_[0-9]+)*
+DNUM          ([0-9]*(_[0-9]+)*[\.]{LNUM}) | ({LNUM}[\.][0-9]*(_[0-9]+)*)
 EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM})
 ]]>
   </programlisting>

Modified: phpdoc/ja/trunk/language/types/integer.xml
===================================================================
--- phpdoc/ja/trunk/language/types/integer.xml	2020-03-14 23:03:38 UTC (rev 349441)
+++ phpdoc/ja/trunk/language/types/integer.xml	2020-03-14 23:15:00 UTC (rev 349442)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 347812 Maintainer: takagi Status: ready -->
+<!-- EN-Revision: 349427 Maintainer: takagi Status: ready -->
 <!-- CREDITS: hirokawa,shimooka,mumumu -->
 <sect1 xml:id="language.types.integer">
  <title>整数</title>
@@ -51,6 +51,12 @@
    2 進数表記を使用する場合、数の前に <literal>0b</literal> を付ける必要があります。
   </para>

+  <para>
+   PHP 7.4.0 以降では、可読性を向上させるために整数リテラルの桁の間にアンダースコア
+   (<literal>_</literal>) を含めることができるようになりました。
+   アンダースコアは PHP の scanner が除去します。
+  </para>
+
   <example>
    <title>整数リテラル</title>
    <programlisting role="php">
@@ -60,6 +66,7 @@
 $a = 0123; // 8進数 (10進数の83と等価)
 $a = 0x1A; // 16進数 (10進数の26と等価)
 $a = 0b11111111; // 2進数 (10進数の255と等価)
+$a = 1_234_567; // 10進数 (PHP 7.4.0 以降)
 ?>
 ]]>
    </programlisting>
@@ -66,20 +73,21 @@
   </example>

   <para>
-   使用可能な整数リテラルの形式は以下のように定義されています。
+   PHP 7.4.0 以降で使用可能な整数リテラルの形式は以下のように定義されています。
+   (これより前のバージョンでは、アンダースコアは許されませんでした)
   </para>

   <informalexample>
    <programlisting>
 <![CDATA[
-decimal     : [1-9][0-9]*
+decimal     : [1-9][0-9]*(_[0-9]+)*
             | 0

-hexadecimal : 0[xX][0-9a-fA-F]+
+hexadecimal : 0[xX][0-9a-fA-F]+(_[0-9a-fA-F]+)*

-octal       : 0[0-7]+
+octal       : 0[0-7]+(_[0-7]+)*

-binary      : 0[bB][01]+
+binary      : 0[bB][01]+(_[01]+)*

 integer     : decimal
             | hexadecimal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.