Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 1607

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>hw_api-&#62;object</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="Hyperwave API Functions"
HREF="ref.hwapi.html"><LINK
REL="PREVIOUS"
TITLE="hw_api_object->value"
HREF="function.hwapi-object-value.html"><LINK
REL="NEXT"
TITLE="hw_api->objectbyanchor"
HREF="function.hwapi-objectbyanchor.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.hwapi-object-value.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.hwapi-objectbyanchor.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.hwapi-object"
></A
>hw_api-&#62;object</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN78682"
></A
><P
>    (no version information, might be only in CVS)</P
>hw_api-&#62;object&nbsp;--&nbsp;Retrieve attribute information</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN78685"
></A
><H2
>Description</H2
>hw_api_object <B
CLASS="methodname"
>hw_api-&#62;object</B
> ( array parameter )<BR
></BR
><P
>&#13;     This function retrieves the attribute information of an object of any
     version. It will not return the document content. The parameter array
     contains the required elements 'objectIdentifier' and the optional
     elements 'attributeSelector' and 'version'.
    </P
><P
>&#13;     The returned object is an instance of class
     <B
CLASS="classname"
>HW_API_Object</B
> on success or
     <B
CLASS="classname"
>HW_API_Error</B
> if an error occurred.
    </P
><P
>&#13;     This simple example retrieves an object and checks for errors.
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN78698"
></A
><P
><B
>例 1. Retrieve an object</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">function </font><font color="#0000BB">handle_error</font><font color="#007700">(</font><font color="#0000BB">$error</font><font color="#007700">) <br />{<br />&nbsp;&nbsp;</font><font color="#0000BB">$reason </font><font color="#007700">= </font><font color="#0000BB">$error</font><font color="#007700">-&gt;</font><font color="#0000BB">reason</font><font color="#007700">(</font><font color="#0000BB">0</font><font color="#007700">);<br />&nbsp;&nbsp;echo </font><font color="#DD0000">"Type: &lt;b&gt;"</font><font color="#007700">;<br />&nbsp;&nbsp;switch (</font><font color="#0000BB">$reason</font><font color="#007700">-&gt;</font><font color="#0000BB">type</font><font color="#007700">()) {<br />&nbsp;&nbsp;&nbsp;&nbsp;case </font><font color="#0000BB">0</font><font color="#007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Error"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;case </font><font color="#0000BB">1</font><font color="#007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Warning"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;case </font><font color="#0000BB">2</font><font color="#007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Message"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;echo </font><font color="#DD0000">"&lt;/b&gt;&lt;br /&gt;\n"</font><font color="#007700">;<br />&nbsp;&nbsp;echo </font><font color="#DD0000">"Description: " </font><font color="#007700">. </font><font color="#0000BB">$reason</font><font color="#007700">-&gt;</font><font color="#0000BB">description</font><font color="#007700">(</font><font color="#DD0000">"en"</font><font color="#007700">) . </font><font color="#DD0000">"&lt;br /&gt;\n"</font><font color="#007700">;<br />}<br /><br />function </font><font color="#0000BB">list_attr</font><font color="#007700">(</font><font color="#0000BB">$obj</font><font color="#007700">) <br />{<br />&nbsp;&nbsp;echo </font><font color="#DD0000">"&lt;table&gt;\n"</font><font color="#007700">;<br />&nbsp;&nbsp;</font><font color="#0000BB">$count </font><font color="#007700">= </font><font color="#0000BB">$obj</font><font color="#007700">-&gt;</font><font color="#0000BB">count</font><font color="#007700">();<br />&nbsp;&nbsp;for (</font><font color="#0000BB">$i</font><font color="#007700">=</font><font color="#0000BB">0</font><font color="#007700">; </font><font color="#0000BB">$i</font><font color="#007700">&lt;</font><font color="#0000BB">$count</font><font color="#007700">; </font><font color="#0000BB">$i</font><font color="#007700">++) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$attr </font><font color="#007700">= </font><font color="#0000BB">$obj</font><font color="#007700">-&gt;</font><font color="#0000BB">attribute</font><font color="#007700">(</font><font color="#0000BB">$i</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">printf</font><font color="#007700">(</font><font color="#DD0000">"&lt;tr&gt;&lt;td align=\"right\" bgcolor=\"#c0c0c0\"&gt;&lt;b&gt;%s&lt;/b&gt;&lt;/td&gt;&lt;td bgcolor=\"#F0F0F0\"&gt;%s&lt;/td&gt;&lt;/tr&gt;\n"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$attr</font><font color="#007700">-&gt;</font><font color="#0000BB">key</font><font color="#007700">(), </font><font color="#0000BB">$attr</font><font color="#007700">-&gt;</font><font color="#0000BB">value</font><font color="#007700">());<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;echo </font><font color="#DD0000">"&lt;/table&gt;\n"</font><font color="#007700">;<br />}<br /><br /></font><font color="#0000BB">$hwapi </font><font color="#007700">= </font><font color="#0000BB">hwapi_hgcsp</font><font color="#007700">(</font><font color="#0000BB">$g_config</font><font color="#007700">[</font><font color="#0000BB">HOSTNAME</font><font color="#007700">]);<br /></font><font color="#0000BB">$parms </font><font color="#007700">= array(</font><font color="#DD0000">"objectIdentifier"</font><font color="#007700">=&gt;</font><font color="#DD0000">"rootcollection"</font><font color="#007700">, </font><font color="#DD0000">"attributeSelector"</font><font color="#007700">=&gt;array(</font><font color="#DD0000">"Title"</font><font color="#007700">, </font><font color="#DD0000">"Name"</font><font color="#007700">, </font><font color="#DD0000">"DocumentType"</font><font color="#007700">));<br /></font><font color="#0000BB">$root </font><font color="#007700">= </font><font color="#0000BB">$hwapi</font><font color="#007700">-&gt;</font><font color="#0000BB">object</font><font color="#007700">(</font><font color="#0000BB">$parms</font><font color="#007700">);<br />if (</font><font color="#0000BB">get_class</font><font color="#007700">(</font><font color="#0000BB">$root</font><font color="#007700">) == </font><font color="#DD0000">"HW_API_Error"</font><font color="#007700">) {<br />&nbsp;&nbsp;</font><font color="#0000BB">handle_error</font><font color="#007700">(</font><font color="#0000BB">$root</font><font color="#007700">);<br />&nbsp;&nbsp;exit;<br />}<br /></font><font color="#0000BB">list_attr</font><font color="#007700">(</font><font color="#0000BB">$root</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     See also <A
HREF="function.hwapi-content.html"
><B
CLASS="function"
>hwapi_content()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.hwapi-object-value.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.hwapi-objectbyanchor.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>hw_api_object-&#62;value</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.hwapi.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>hw_api-&#62;objectbyanchor</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>