Files
php-doc-ru/reference/var/functions/floatval.xml
2023-07-01 11:54:02 +03:00

138 lines
4.2 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: fca3920773bcf7ea2aa2f7306103f6d3d0e6b901 Maintainer: shein Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.floatval" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>floatval</refname>
<refpurpose>Возвращает значение переменной в виде числа с плавающей точкой</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>float</type><methodname>floatval</methodname>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
Возвращает значение переменной <parameter>value</parameter> в виде числа с плавающей точкой (<type>float</type>).
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
Может быть любого скалярного типа. <function>floatval</function>
нельзя использовать с объектами, в этом случае возникнет
ошибка уровня <constant>E_WARNING</constant> и функция вернёт 1.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Значение заданной переменной в виде числа с плавающей точкой.
Пустые массивы в качестве аргумента возвращают 0, непустые
массивы возвращают 1.
</para>
<para>
Строки чаще всего возвращают 0, тем не менее результат зависит
от самых левых символов строки. Применяются правила
<link linkend="language.types.float.casting">приведения к float</link>.
</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>
Уровень ошибки при преобразовании из объекта был изменён
с <constant>E_NOTICE</constant> на <constant>E_WARNING</constant>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>floatval</function></title>
<programlisting role="php">
<![CDATA[
<?php
$var = '122.34343The';
$float_value_of_var = floatval($var);
echo $float_value_of_var; // 122.34343
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Пример использования <function>floatval</function> с нечисловыми крайними левыми символами</title>
<programlisting role="php">
<![CDATA[
<?php
$var = 'The122.34343';
$float_value_of_var = floatval($var);
echo $float_value_of_var; // 0
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>boolval</function></member>
<member><function>intval</function></member>
<member><function>strval</function></member>
<member><function>settype</function></member>
<member><link linkend="language.types.type-juggling">Манипуляции с типами</link></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
-->