mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-24 08:52:09 +01:00
159 lines
4.2 KiB
XML
159 lines
4.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 4a07033f7ac5ab121357051cc94ec48b9f6f58fc Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
<refentry xml:id="function.empty" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>empty</refname>
|
|
<refpurpose>Détermine si une variable est vide</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>empty</methodname>
|
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Détermine si une variable est considérée comme vide.
|
|
Une variable est considérée comme vide si elle n'existe pas,
|
|
ou si sa valeur équivaut à &false;. La fonction <function>empty</function>
|
|
ne génère pas d'alerte si la variable n'existe pas.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>var</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Variable à vérifier.
|
|
</para>
|
|
<para>
|
|
Aucune alerte n'est générée si la variable n'existe pas. Cela signifie que
|
|
<function>empty</function> est strictement équivalent à
|
|
<command>!isset($var) || $var == false</command>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retourne &true; si <parameter>var</parameter> n'existe pas ou a une
|
|
valeur vide ou égale à zéro, c.à.d. qu'elle est considérée "false", voir
|
|
<link linkend="language.types.boolean.casting">conversion en booléen</link>.
|
|
Sinon retourne &false;.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>
|
|
Une comparaison simple <function>empty</function> / <function>isset</function>.
|
|
</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$var = 0;
|
|
|
|
// Évaluée à vrai car $var est vide
|
|
if (empty($var)) {
|
|
echo '$var vaut soit 0, vide, ou pas définie du tout';
|
|
}
|
|
|
|
// Évaluée à vrai car $var est définie
|
|
if (isset($var)) {
|
|
echo '$var est définie même si elle est vide';
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<example>
|
|
<title><function>empty</function> sur des positions dans une chaîne</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$expected_array_got_string = 'somestring';
|
|
var_dump(empty($expected_array_got_string['some_key']));
|
|
var_dump(empty($expected_array_got_string[0]));
|
|
var_dump(empty($expected_array_got_string['0']));
|
|
var_dump(empty($expected_array_got_string[0.5]));
|
|
var_dump(empty($expected_array_got_string['0.5']));
|
|
var_dump(empty($expected_array_got_string['0 Mostel']));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
bool(true)
|
|
bool(false)
|
|
bool(false)
|
|
bool(false)
|
|
bool(true)
|
|
bool(true)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.language-construct;
|
|
<note>
|
|
<para>
|
|
Lors de l'utilisation de cette fonction sur des propriétés d'objet
|
|
inaccessibles, la méthode magique
|
|
<link linkend="object.isset">__isset()</link>
|
|
sera appelée, si elle existe.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>isset</function></member>
|
|
<member><link linkend="object.isset">__isset()</link></member>
|
|
<member><function>unset</function></member>
|
|
<member><function>array_key_exists</function></member>
|
|
<member><function>count</function></member>
|
|
<member><function>strlen</function></member>
|
|
<member><link linkend="types.comparisons">Les tables de comparaison des types</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
|
|
-->
|