⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sxe_004.phpt

📁 PHP v6.0 For Linux 运行环境:Win9X/ WinME/ WinNT/ Win2K/ WinXP
💻 PHPT
字号:
--TEST--SPL: SimpleXMLIterator and getChildren()--SKIPIF--<?php if (!extension_loaded("spl")) print "skip";if (!extension_loaded('simplexml')) print 'skip';if (!extension_loaded("libxml")) print "skip LibXML not present";if (!class_exists('RecursiveIteratorIterator')) print 'skip RecursiveIteratorIterator not available';?>--FILE--<?php $xml =<<<EOF<?xml version='1.0'?><!DOCTYPE sxe SYSTEM "notfound.dtd"><sxe id="elem1"> Plain text. <elem1 attr1='first'>  Bla bla 1.  <!-- comment -->  <elem2>   Here we have some text data.   <elem3>    And here some more.    <elem4>     Wow once again.    </elem4>   </elem3>  </elem2> </elem1> <elem11 attr2='second'>  Bla bla 2.  <elem111>   Foo Bar  </elem111> </elem11></sxe>EOF;class SXETest extends SimpleXMLIterator{	function rewind()	{		echo __METHOD__ . "\n";		return parent::rewind();	}	function valid()	{		echo __METHOD__ . "\n";		return parent::valid();	}	function current()	{		echo __METHOD__ . "\n";		return parent::current();	}	function key()	{		echo __METHOD__ . "\n";		return parent::key();	}	function next()	{		echo __METHOD__ . "\n";		return parent::next();	}	function hasChildren()	{		echo __METHOD__ . "\n";		return parent::hasChildren();	}	function getChildren()	{		echo __METHOD__ . "\n";		return parent::getChildren();	}}$sxe = new SXETest($xml);$rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::SELF_FIRST);foreach($rit as $data) {	var_dump(get_class($data));	var_dump(trim($data));}?>===DONE===--EXPECTF--SXETest::rewindSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentstring(7) "SXETest"string(10) "Bla bla 1."SXETest::getChildrenSXETest::rewindSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentstring(7) "SXETest"string(28) "Here we have some text data."SXETest::getChildrenSXETest::rewindSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentstring(7) "SXETest"string(19) "And here some more."SXETest::getChildrenSXETest::rewindSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentstring(7) "SXETest"string(15) "Wow once again."SXETest::nextSXETest::validSXETest::nextSXETest::validSXETest::nextSXETest::validSXETest::nextSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentstring(7) "SXETest"string(10) "Bla bla 2."SXETest::getChildrenSXETest::rewindSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentstring(7) "SXETest"string(7) "Foo Bar"SXETest::nextSXETest::validSXETest::nextSXETest::validSXETest::valid===DONE===--UEXPECTF--SXETest::rewindSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentunicode(7) "SXETest"unicode(10) "Bla bla 1."SXETest::getChildrenSXETest::rewindSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentunicode(7) "SXETest"unicode(28) "Here we have some text data."SXETest::getChildrenSXETest::rewindSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentunicode(7) "SXETest"unicode(19) "And here some more."SXETest::getChildrenSXETest::rewindSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentunicode(7) "SXETest"unicode(15) "Wow once again."SXETest::nextSXETest::validSXETest::nextSXETest::validSXETest::nextSXETest::validSXETest::nextSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentunicode(7) "SXETest"unicode(10) "Bla bla 2."SXETest::getChildrenSXETest::rewindSXETest::validSXETest::hasChildrenSXETest::validSXETest::currentunicode(7) "SXETest"unicode(7) "Foo Bar"SXETest::nextSXETest::validSXETest::nextSXETest::validSXETest::valid===DONE===

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -