mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-25 17:32:07 +01:00
214 lines
4.8 KiB
XML
214 lines
4.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 1f91a4b0fb7bb5a44d8033806bd2f554472f5f00 Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
<refentry xml:id="function.is-numeric" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>is_numeric</refname>
|
|
<refpurpose>
|
|
Détermine si une variable est un nombre ou une chaîne numérique
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>is_numeric</methodname>
|
|
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Détermine si la variable donnée est un nombre ou une
|
|
<link linkend="language.types.numeric-strings">chaîne numérique</link>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>value</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La variable à évaluer.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retourne &true; si <parameter>value</parameter> est un nombre ou une
|
|
<link linkend="language.types.numeric-strings">chaîne numérique</link>,
|
|
&false; sinon.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
Les châines numériques terminant avec des caractères d'espacement blanc
|
|
(<literal>"42 "</literal>) retourneront désormais &true;.
|
|
Auparavant, &false; était retourné à la place.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>is_numeric</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$tests = array(
|
|
"42",
|
|
1337,
|
|
0x539,
|
|
02471,
|
|
0b10100111001,
|
|
1337e0,
|
|
"0x539",
|
|
"02471",
|
|
"0b10100111001",
|
|
"1337e0",
|
|
"not numeric",
|
|
array(),
|
|
9.1,
|
|
null,
|
|
'',
|
|
);
|
|
|
|
foreach ($tests as $element) {
|
|
if (is_numeric($element)) {
|
|
echo var_export($element, true) . " est numérique", PHP_EOL;
|
|
} else {
|
|
echo var_export($element, true) . " N'est PAS numérique", PHP_EOL;
|
|
}
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
'42' est numérique
|
|
1337 est numérique
|
|
1337 est numérique
|
|
1337 est numérique
|
|
1337 est numérique
|
|
1337.0 est numérique
|
|
'0x539' N'est PAS numérique
|
|
'02471' est numérique
|
|
'0b10100111001' N'est PAS numérique
|
|
'1337e0' est numérique
|
|
'not numeric' N'est PAS numérique
|
|
array (
|
|
) N'est PAS numérique
|
|
9.1 est numérique
|
|
NULL N'est PAS numérique
|
|
'' N'est PAS numérique
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>is_numeric</function> avec des caractères d'espacement blanc</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$tests = [
|
|
" 42",
|
|
"42 ",
|
|
" 9001", // non-breaking space
|
|
"9001 ", // non-breaking space
|
|
];
|
|
|
|
foreach ($tests as $element) {
|
|
if (is_numeric($element)) {
|
|
echo var_export($element, true) . " is numeric", PHP_EOL;
|
|
} else {
|
|
echo var_export($element, true) . " is NOT numeric", PHP_EOL;
|
|
}
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.8;
|
|
<screen>
|
|
<![CDATA[
|
|
' 42' is numeric
|
|
'42 ' is numeric
|
|
' 9001' is NOT numeric
|
|
'9001 ' is NOT numeric
|
|
]]>
|
|
</screen>
|
|
&example.outputs.7;
|
|
<screen>
|
|
<![CDATA[
|
|
' 42' is numeric
|
|
'42 ' is NOT numeric
|
|
' 9001' is NOT numeric
|
|
'9001 ' is NOT numeric
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><link linkend="language.types.numeric-strings">Les chaînes numérique</link></member>
|
|
<member><function>ctype_digit</function></member>
|
|
<member><function>is_bool</function></member>
|
|
<member><function>is_null</function></member>
|
|
<member><function>is_float</function></member>
|
|
<member><function>is_int</function></member>
|
|
<member><function>is_string</function></member>
|
|
<member><function>is_object</function></member>
|
|
<member><function>is_array</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- 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
|
|
-->
|