1
0
mirror of https://github.com/php/doc-ja.git synced 2026-03-24 07:02:08 +01:00
Files
archived-doc-ja/reference/var/functions/is-numeric.xml
Yoshinari Takaoka 37f36b3194 Updated EN-Revision only / Fix typo (return → returned)
日本語版は修正不要だった

0817d5b283
2023-01-06 19:34:37 +09:00

220 lines
5.0 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 0817d5b2835f8a47314823338d983fa2c5005dfc Maintainer: hirokawa Status: ready -->
<!-- CREDITS: takagi,mumumu -->
<refentry xml:id="function.is-numeric" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>is_numeric</refname>
<refpurpose>
変数が数字または数値形式の文字列であるかを調べる
</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>
指定した変数が数値または
<link linkend="language.types.numeric-strings">数値形式の文字列</link>であるかどうかを調べます。
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
評価する変数。
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<parameter>value</parameter> が数値または
<link linkend="language.types.numeric-strings">数値形式の文字列</link>
である場合に
&true;、それ以外の場合に &false; を返します。
</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>
空白文字で終わる数値形式の文字列
(<literal>"42 "</literal>)
に対して、この関数は &true; を返すようになりました。
これより前のバージョンでは、&false; を返していました。
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><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) . " is numeric", PHP_EOL;
} else {
echo var_export($element, true) . " is NOT numeric", PHP_EOL;
}
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
'42' is numeric
1337 is numeric
1337 is numeric
1337 is numeric
1337 is numeric
1337.0 is numeric
'0x539' is NOT numeric
'02471' is numeric
'0b10100111001' is NOT numeric
'1337e0' is numeric
'not numeric' is NOT numeric
array (
) is NOT numeric
9.1 is numeric
NULL is NOT numeric
'' is NOT numeric
]]>
</screen>
</example>
</para>
<para>
<example>
<title>空白文字と <function>is_numeric</function> 関数</title>
<programlisting role="php">
<![CDATA[
<?php
$tests = [
" 42",
"42 ",
"\u{A0}9001", // non-breaking space
"9001\u{A0}", // 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">数値形式の文字列</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>
<member><function>filter_var</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
-->