mirror of
https://github.com/php/doc-fr.git
synced 2026-03-24 07:02:06 +01:00
101 lines
2.8 KiB
XML
101 lines
2.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 28f122648d4f4b0c23d36dbfb5950da50c501b18 Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
|
|
<chapter xml:id="com.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
&reftitle.examples;
|
|
|
|
<section xml:id="com.examples.foreach">
|
|
<title>For Each</title>
|
|
<para>
|
|
Il est possible d'utiliser la structure de contrôle &foreach;
|
|
de PHP pour passer en boucle à travers le contenu d'un IEnumVariant COM/OLE standard.
|
|
Cela signifie qu'il est possible d'utiliser &foreach; aux endroits où
|
|
on aurait pu utiliser <literal>For Each</literal> dans du code VB/ASP.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>For Each en ASP</title>
|
|
<programlisting role="asp">
|
|
<![CDATA[
|
|
<%
|
|
Set domainObject = GetObject("WinNT://Domain")
|
|
For Each obj in domainObject
|
|
Response.Write obj.Name & "<br />"
|
|
Next
|
|
%>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Foreach en PHP</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$domainObject = new COM("WinNT://Domain");
|
|
foreach ($domainObject as $obj) {
|
|
echo $obj->Name . "<br />";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</section>
|
|
|
|
<section xml:id="com.examples.arrays">
|
|
<title>Tableaux et propriétés à la façon des tableaux de COM</title>
|
|
<para>
|
|
Plusieurs objets COM exposent leurs propriétés comme tableaux, ou en
|
|
utilisant un chemin d'accès à la façon des tableaux.
|
|
</para>
|
|
<para>
|
|
Il est possible de :
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
Accéder aux tableaux multidimensionnels ou aux propriétés COM qui
|
|
requièrent plusieurs paramètres comme si l'on accédait à un tableau.
|
|
Il est aussi possible d'écrire ces propriétés en utilisant cette technique.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Boucler sur les SafeArrays ("vrais" tableaux) en utilisant la structure
|
|
de contrôle &foreach;. Cela fonctionne
|
|
car un SafeArray comporte des informations à propos de sa taille. Si
|
|
une propriété à la façon des tableaux implémente IEnumVariant, alors on
|
|
peut aussi utiliser &foreach; pour cette propriété ; consulter <xref
|
|
linkend="com.examples.foreach"/> pour plus d'informations à ce sujet.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</section>
|
|
|
|
</chapter>
|
|
|
|
<!-- 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
|
|
-->
|