mirror of
https://github.com/macintoshplus/doc-en.git
synced 2026-03-24 17:02:07 +01:00
1) There's a typo in the variable name 2) The call returned NULL in PHP < 8.1. It throws an exception starting in 8.1. To keep the example simple and not introduce different variants based on the version, just remove the faulty call and expand upon the comment.
132 lines
3.2 KiB
XML
132 lines
3.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="simplexmlelement.current" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>SimpleXMLElement::current</refname>
|
|
<refpurpose>Returns the current element</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis role="SimpleXMLElement">
|
|
<modifier>public</modifier> <type>SimpleXMLElement</type><methodname>SimpleXMLElement::current</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
|
|
<warning>
|
|
<simpara>
|
|
Prior to PHP 8.0, <methodname>SimpleXMLElement::current</methodname> was only
|
|
declared on the subclass <classname>SimpleXMLIterator</classname>.
|
|
</simpara>
|
|
</warning>
|
|
|
|
<para>
|
|
This method returns the current element as a <classname>SimpleXMLElement</classname> object.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
&no.function.parameters;
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns the current element as a <classname>SimpleXMLElement</classname> object.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
Throws an <classname>Error</classname> on failure.
|
|
</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.1.0</entry>
|
|
<entry>
|
|
An <classname>Error</classname> is now thrown if
|
|
<methodname>SimpleXMLElement::current</methodname> is called on an
|
|
invalid iterator. Previously, &null; was returned.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Return the current element</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$xmlElement = new SimpleXMLElement('<books><book>PHP basics</book><book>XML basics</book></books>');
|
|
|
|
$xmlElement->rewind(); // rewind to first element, otherwise current() won't work
|
|
var_dump($xmlElement->current());
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
object(SimpleXMLElement)#2 (1) {
|
|
[0]=>
|
|
string(10) "PHP basics"
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><methodname>SimpleXMLElement::key</methodname></member>
|
|
<member><methodname>SimpleXMLElement::next</methodname></member>
|
|
<member><methodname>SimpleXMLElement::rewind</methodname></member>
|
|
<member><methodname>SimpleXMLElement::valid</methodname></member>
|
|
<member><classname>SimpleXMLElement</classname></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
|
|
-->
|