[DOC-CVS] [doc-en] master: Clarify intval() behavior with scientific notation numeric strings (#5098)

[email protected] (Louis-Arnaud via GitHub) Wed, 22 Apr 2026 13:21:56 +0000
Newsgroups php.doc.cvs
Message-ID <[email protected]>
Author: Louis-Arnaud (lacatoire)
Committer: GitHub (web-flow)
Pusher: kamil-tekiela
Date: 2026-04-22T14:21:53+01:00

Commit: https://github.com/php/doc-en/commit/6197a68b1e9bc777323fa0df01adbed4d0c743f4
Raw diff: https://github.com/php/doc-en/commit/6197a68b1e9bc777323fa0df01adbed4d0c743f4.diff

Clarify intval() behavior with scientific notation numeric strings (#5098)

Changed paths:
  M  reference/var/functions/intval.xml


Diff:

diff --git a/reference/var/functions/intval.xml b/reference/var/functions/intval.xml
index 77fe1d944910..60ecbb999211 100644
--- a/reference/var/functions/intval.xml
+++ b/reference/var/functions/intval.xml
@@ -96,6 +96,31 @@
    <link linkend="language.types.integer.casting">integer casting</link> 
    apply.
   </para>
+  <note>
+   <simpara>
+    Numeric strings using scientific notation (containing the letter
+    <literal>e</literal> or <literal>E</literal>) are first parsed as
+    numbers before being converted to an integer.
+   </simpara>
+   <simpara>
+    Because the numeric part of the string is parsed as a whole, the result
+    is not simply the leading integer part. Large exponents can additionally
+    overflow to <constant>PHP_INT_MAX</constant>:
+   </simpara>
+   <informalexample>
+    <programlisting role="php">
+<![CDATA[
+<?php
+echo intval('42.42e42'); // 9223372036854775807 on 64-bit systems
+?>
+]]>
+    </programlisting>
+   </informalexample>
+   <simpara>
+    See <link linkend="language.types.numeric-strings">Numeric strings</link>
+    for details on how such strings are interpreted.
+   </simpara>
+  </note>
  </refsect1>
 
  <refsect1 role="changelog">