diff --git a/language/oop5.xml b/language/oop5.xml index bfb592157..b80cd3b96 100755 --- a/language/oop5.xml +++ b/language/oop5.xml @@ -1,6 +1,6 @@ - - + + Classes e Objetos diff --git a/language/oop5/abstract.xml b/language/oop5/abstract.xml index fa6c2d153..91283dd39 100755 --- a/language/oop5/abstract.xml +++ b/language/oop5/abstract.xml @@ -1,5 +1,5 @@ - + Abstração de Classes @@ -194,8 +194,8 @@ class C extends A mas deve ter get ou set declarado, mas não definido (como no exemplo acima). - Exemplo de propriedade abstrata - + Exemplo de propriedade abstrata com ganchos + - + Classes anônimas @@ -185,9 +185,8 @@ class@anonymous/in/oNi1A0x7f8636ad2021 setLogger(new readonly class('[DEBUG]') { +var_dump(new readonly class('[DEBUG]') { public function __construct(private string $prefix) { } diff --git a/language/oop5/autoload.xml b/language/oop5/autoload.xml index 9b4577405..44d5aeb36 100644 --- a/language/oop5/autoload.xml +++ b/language/oop5/autoload.xml @@ -1,5 +1,5 @@ - + Autocarregamento de Classes @@ -44,7 +44,7 @@ e MyClass2 dos arquivos MyClass1.php e MyClass2.php, respectivamente. - + - + - + O básico @@ -224,11 +224,16 @@ readonly class Foo ]]> @@ -296,6 +301,9 @@ object(ClasseD)#1 (0) { format('Y'); +echo (new DateTime())->format('Y'), PHP_EOL; + // parênteses envolvendo o objeto são opcionais a partir do PHP 8.4.0 -echo new DateTime()->format('Y'); +echo new DateTime()->format('Y'), PHP_EOL; ?> ]]> &example.outputs.similar; @@ -498,6 +508,14 @@ echo ($obj->bar)(), PHP_EOL; ]]> @@ -788,7 +807,7 @@ NS\ClassName Operador nullsafe - + - + Construtores e Destrutores @@ -193,7 +193,7 @@ class Point { New em inicializações - + 1005Elephpant"; + class Product { private ?int $id; @@ -256,12 +259,11 @@ class Product { return new static($data['id'], $data['name']); } - public static function fromXml(string $xml): static { - // Custom logic here. - $data = convert_xml_to_array($xml); + public static function fromXml(string $xml): static {a + $data = simplexml_load_string($xml); $new = new static(); - $new->id = $data['id']; - $new->name = $data['name']; + $new->id = $data->id; + $new->name = $data->name; return $new; } } @@ -269,6 +271,8 @@ class Product { $p1 = Product::fromBasicData(5, 'Widget'); $p2 = Product::fromJson($some_json_string); $p3 = Product::fromXml($some_xml_string); + +var_dump($p1, $p2, $p3); ]]> diff --git a/language/oop5/overloading.xml b/language/oop5/overloading.xml index bf5d891cc..3f4325db5 100755 --- a/language/oop5/overloading.xml +++ b/language/oop5/overloading.xml @@ -1,5 +1,5 @@ - + Sobrecarga @@ -186,8 +186,6 @@ class PropertyTest } -echo "
\n";
-
 $obj = new PropertyTest;
 
 $obj->a = 1;
diff --git a/language/oop5/paamayim-nekudotayim.xml b/language/oop5/paamayim-nekudotayim.xml
index c1d24a322..b47064bcc 100755
--- a/language/oop5/paamayim-nekudotayim.xml
+++ b/language/oop5/paamayim-nekudotayim.xml
@@ -1,5 +1,5 @@
 
-
+
 
  Operador de Resolução de Escopo (::)
 
@@ -61,6 +61,10 @@ echo MyClass::CONST_VALUE;
   
 
-
+
  
   Propriedades
 
@@ -45,7 +45,7 @@
   
    
     Declaração de propriedades
-    
+    
 
      Exemplo de propriedade somente leitura
-     
+     
 prop = "foobar";
     Uma propriedade somente leitura somente pode ser inicializada uma única vez, e somente do escopo onde ela foi declarada. Quaisquer outras modificações da propriedade resultam em um Error.
     
      Inicilização ilegal de propriedades somente leitura.
-     
+     
 prop = "foobar";
     
      Especificar um valor default para uma propriedade somente leitura não é permitido, porque uma propriedade com um valor default é essencialmente uma constante, e portanto não tem outro propósito.
      
-      
+      
 
     Nenhum tipo de modificação é permitido, e o seguintes casos resultarão em um Error:
     
-     
+     
 
     Entretanto, propriedades somente leitura não proíbem mutação. Objetos ou recursos armazenados em propriedades somente leitura ainda podem ser modificados internamente:
     
-     
+     
 
-
+
 
  Ganchos de Propriedade
 
@@ -220,6 +220,7 @@ class Example
    
    
 
    
 
-
+
  
   Traits
   
@@ -220,7 +220,7 @@ Hello World!
       para perrmitir o uso da implementação bigTalk da Trait B sob um apelido adicional
       talk.
     
-    
+    
 
    
     Exemplo de Mudança de Visibilidade de Método
-    
+    
 
-
+
  
   Visibilidade
   
@@ -22,7 +22,7 @@
    
    
     Declaração de propriedade
-    
+    
 imprimeAlo(); // Mostra Public, Protected2, Undefined
     
     
      Visibilidade de propriedade assimétrica
-     
+     
 pubYear = 2023; // Erro fatal
     
     
      Herança de propriedade assimétrica
-     
+     
 
    
     Declaração de método
-    
+    
 test(); // Bar::testPrivate
    
    
     Declaração de constantes (desde o PHP 7.1.0)
-    
+    
 foo2(); // Public e Protected funcionam, mas não Private
    
    
     Acessando membros privados entre objetos do mesmo tipo
-    
+    
 
-
+
 
-
+
  
  Document Object Model
  DOM
diff --git a/reference/dom/dom/attr/isid.xml b/reference/dom/dom/attr/isid.xml
index 78d044a47..d49f33670 100644
--- a/reference/dom/dom/attr/isid.xml
+++ b/reference/dom/dom/attr/isid.xml
@@ -1,4 +1,4 @@
-
+
 
  
   Dom\Attr::isId
@@ -40,7 +40,7 @@
 getElementsByTagName('chapter')->item(0)->getAttributeNode('id');
diff --git a/reference/dom/domattr/construct.xml b/reference/dom/domattr/construct.xml
index db91203d8..28b8b7bc9 100644
--- a/reference/dom/domattr/construct.xml
+++ b/reference/dom/domattr/construct.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMAttr::__construct
@@ -52,7 +52,7 @@
 appendChild(new DOMElement('root'));
 $attr = $element->setAttributeNode(new DOMAttr('attr', 'attrvalue'));
 echo $dom->saveXML();
@@ -64,7 +64,7 @@ echo $dom->saveXML();
     
 
-
+
 ]]>
     
    
diff --git a/reference/dom/domattr/isid.xml b/reference/dom/domattr/isid.xml
index 96e76dc7a..3755cc609 100644
--- a/reference/dom/domattr/isid.xml
+++ b/reference/dom/domattr/isid.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMAttr::isId
@@ -48,7 +48,7 @@ $doc = new DOMDocument();
 
 // Precisamos validar nosso documento antes de referenciar o id
 $doc->validateOnParse = true;
-$doc->load('book.xml');
+$doc->load('examples/book-docbook.xml');
 
 // Recuperamos o atributo chamado id do elemento chapter
 $attr = $doc->getElementsByTagName('chapter')->item(0)->getAttributeNode('id');
diff --git a/reference/dom/domdocument/adoptnode.xml b/reference/dom/domdocument/adoptnode.xml
index 97b57d9f4..6c7ee745e 100644
--- a/reference/dom/domdocument/adoptnode.xml
+++ b/reference/dom/domdocument/adoptnode.xml
@@ -1,5 +1,4 @@
-
-
+
 
  
   DOMDocument::adoptNode
@@ -72,7 +71,7 @@ $doc2 = new DOMDocument;
 $doc2->loadXML("");
 $doc2->documentElement->appendChild($doc2->adoptNode($hello));
 
-echo $doc1->saveXML() . PHP_EOL;
+echo $doc1->saveXML() . PHP_EOL . PHP_EOL;
 echo $doc2->saveXML();
 ?>
 ]]>
diff --git a/reference/dom/domdocument/getelementbyid.xml b/reference/dom/domdocument/getelementbyid.xml
index 13986eefb..b3f130c6b 100644
--- a/reference/dom/domdocument/getelementbyid.xml
+++ b/reference/dom/domdocument/getelementbyid.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMDocument::getElementById
@@ -60,9 +60,9 @@ $doc = new DomDocument;
 
 // Precisamos validar nosso documento antes de referenciar o ID
 $doc->validateOnParse = true;
-$doc->Load('book.xml');
+$doc->load('examples/book.xml');
 
-echo "The element whose id is 'php-basics' is: " . $doc->getElementById('php-basics')->tagName . "\n";
+echo "O elemento cujo ID é 'php-basics' é: " . $doc->getElementById('php-basics')->tagName . "\n";
 
 ?>
 ]]>
@@ -70,7 +70,7 @@ echo "The element whose id is 'php-basics' is: " . $doc->getElementById('php-bas
    &example.outputs;
    
 
    
   
diff --git a/reference/dom/domdocument/load.xml b/reference/dom/domdocument/load.xml
index 5acdcfafe..d2f974e1a 100644
--- a/reference/dom/domdocument/load.xml
+++ b/reference/dom/domdocument/load.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMDocument::load
@@ -103,7 +103,7 @@
 load('book.xml');
+$doc->load('examples/book.xml');
 echo $doc->saveXML();
 ?>
 ]]>
diff --git a/reference/dom/domdocument/replacechildren.xml b/reference/dom/domdocument/replacechildren.xml
index 40ca6c88d..f7a5ea2ca 100644
--- a/reference/dom/domdocument/replacechildren.xml
+++ b/reference/dom/domdocument/replacechildren.xml
@@ -1,5 +1,4 @@
-
-
+
 
  
   DOMDocument::replaceChildren
@@ -27,7 +26,7 @@
   
    Exemplo de <methodname>DOMDocument::replaceChildren</methodname>
    
-    Substitui os filhos por novos nodes.
+    Substitui os filhos por novos nós.
    
    
 loadXML("");
 
-$doc->replaceWith("beautiful", $doc->createElement("world"));
+$doc->replaceChildren("beautiful", $doc->createElement("world"));
 
 echo $doc->saveXML();
 ?>
diff --git a/reference/dom/domdocument/validate.xml b/reference/dom/domdocument/validate.xml
index 81611f686..cd8f27f5d 100644
--- a/reference/dom/domdocument/validate.xml
+++ b/reference/dom/domdocument/validate.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMDocument::validate
@@ -43,7 +43,7 @@
 load('book.xml');
+$dom->load('examples/book.xml');
 if ($dom->validate()) {
     echo "Este documento é válido!\n";
 }
@@ -58,7 +58,7 @@ if ($dom->validate()) {
 validateOnParse = true;
-$dom->load('book.xml');
+$dom->load('examples/book.xml');
 ?>
 ]]>
     
diff --git a/reference/dom/domdocument/xinclude.xml b/reference/dom/domdocument/xinclude.xml
index 408562cd4..f4ba30e5b 100644
--- a/reference/dom/domdocument/xinclude.xml
+++ b/reference/dom/domdocument/xinclude.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMDocument::xinclude
@@ -57,7 +57,7 @@ $xml = <<
  Books of the other guy..
  
-  
+  
    
     xinclude: book.xml not found
    
diff --git a/reference/dom/domdocumentfragment/replacechildren.xml b/reference/dom/domdocumentfragment/replacechildren.xml
index 40a03e754..ba9483f9d 100644
--- a/reference/dom/domdocumentfragment/replacechildren.xml
+++ b/reference/dom/domdocumentfragment/replacechildren.xml
@@ -1,5 +1,4 @@
-
-
+
 
  
   DOMDocumentFragment::replaceChildren
@@ -37,7 +36,7 @@ $doc->loadXML("");
 $fragment = $doc->createDocumentFragment();
 $fragment->append("hello");
 
-$fragment->replaceWith("beautiful", $doc->createElement("world"));
+$fragment->replaceChildren("beautiful", $doc->createElement("world"));
 
 echo $doc->saveXML($fragment);
 ?>
diff --git a/reference/dom/domnamednodemap/getnameditem.xml b/reference/dom/domnamednodemap/getnameditem.xml
index 4418947d3..5d5359c0f 100644
--- a/reference/dom/domnamednodemap/getnameditem.xml
+++ b/reference/dom/domnamednodemap/getnameditem.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMNamedNodeMap::getNamedItem
@@ -46,12 +46,10 @@
    
 load('book.xml');
-
-$id = $doc->firstChild->attributes->getNamedItem('id');
+$doc->load('examples/book.xml');
 
+$id = $doc->firstChild->nextSibling->nextSibling->firstChild->nextSibling->attributes->getNamedItem('id');
 ?>
 ]]>
    
@@ -61,9 +59,11 @@ $id = $doc->firstChild->attributes->getNamedItem('id');
    
 load('examples/book.xml');
 
-$id = $doc->firstChild->attributes['id'];
 
+$id = $doc->firstChild->nextSibling->nextSibling->firstChild->nextSibling->attributes['id'];
 ?>
 ]]>
    
diff --git a/reference/dom/domnode/removechild.xml b/reference/dom/domnode/removechild.xml
index 7a8110b6e..8e72cacd2 100644
--- a/reference/dom/domnode/removechild.xml
+++ b/reference/dom/domnode/removechild.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMNode::removeChild
@@ -72,7 +72,7 @@
 load('book.xml');
+$doc->load('examples/book-docbook.xml');
 
 $book = $doc->documentElement;
 
diff --git a/reference/dom/domnodelist/item.xml b/reference/dom/domnodelist/item.xml
index 681d0b4b0..609a05c4b 100644
--- a/reference/dom/domnodelist/item.xml
+++ b/reference/dom/domnodelist/item.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMNodeList::item
@@ -56,16 +56,14 @@
     
 load('book.xml');
+$doc->load('examples/book-docbook.xml');
 
 $items = $doc->getElementsByTagName('entry');
 
 for ($i = 0; $i < $items->length; $i++) {
     echo $items->item($i)->nodeValue . "\n";
 }
-
 ?>
 ]]>
     
@@ -75,6 +73,10 @@ for ($i = 0; $i < $items->length; $i++) {
     
 load('examples/book-docbook.xml');
+
+$items = $doc->getElementsByTagName('entry');
 
 for ($i = 0; $i < $items->length; $i++) {
     echo $items[$i]->nodeValue . "\n";
@@ -89,11 +91,14 @@ for ($i = 0; $i < $items->length; $i++) {
     
 load('examples/book-docbook.xml');
+
+$items = $doc->getElementsByTagName('entry');
 
 foreach ($items as $item) {
     echo $item->nodeValue . "\n";
 }
-
 ?>
 ]]>
     
diff --git a/reference/dom/domxpath/evaluate.xml b/reference/dom/domxpath/evaluate.xml
index 375fd9e5f..0e651ada4 100644
--- a/reference/dom/domxpath/evaluate.xml
+++ b/reference/dom/domxpath/evaluate.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMXPath::evaluate
@@ -70,7 +70,7 @@
 
 $doc = new DOMDocument;
 
-$doc->load('book.xml');
+$doc->load('examples/book-dcobook.xml');
 
 $xpath = new DOMXPath($doc);
 
diff --git a/reference/dom/domxpath/query.xml b/reference/dom/domxpath/query.xml
index 966a69ddf..9bba18d01 100644
--- a/reference/dom/domxpath/query.xml
+++ b/reference/dom/domxpath/query.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMXPath::query
@@ -102,7 +102,7 @@ $doc = new DOMDocument;
 // Não queremos nos preocupar com espaços em branco
 $doc->preserveWhiteSpace = false;
 
-$doc->load('book.xml');
+$doc->load('examples/book-docbook.xml');
 
 $xpath = new DOMXPath($doc);
 
@@ -136,7 +136,7 @@ Found The Pearl, by John Steinbeck
 $doc = new DOMDocument;
 $doc->preserveWhiteSpace = false;
 
-$doc->load('book.xml');
+$doc->load('examples/book-docbook.xml');
 
 $xpath = new DOMXPath($doc);
 
diff --git a/reference/dom/domxpath/registerphpfunctions.xml b/reference/dom/domxpath/registerphpfunctions.xml
index 7a2403baf..bc3009ae0 100644
--- a/reference/dom/domxpath/registerphpfunctions.xml
+++ b/reference/dom/domxpath/registerphpfunctions.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   DOMXPath::registerPhpFunctions
@@ -137,7 +137,7 @@
 load('book.xml');
+$doc->load('examples/book-simple.xml');
 
 $xpath = new DOMXPath($doc);
 
@@ -177,7 +177,7 @@ PHP Secrets by Jenny Smythe
 load('book.xml');
+$doc->load('examples/book-simple.xml');
 
 $xpath = new DOMXPath($doc);
 
@@ -218,7 +218,7 @@ PHP Basics
 load('book.xml');
+$doc->load('examples/book-simple.xml');
 
 $xpath = new DOMXPath($doc);
 
diff --git a/reference/filesystem/functions/dirname.xml b/reference/filesystem/functions/dirname.xml
index a0c740b45..e40373545 100644
--- a/reference/filesystem/functions/dirname.xml
+++ b/reference/filesystem/functions/dirname.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   dirname
@@ -103,30 +103,6 @@ dirname('C:\\'); // Retornará 'C:\' no Windows e '.' em sistemas *nix.
   
  
 
- 
-  &reftitle.changelog;
-  
-   
-    
-     
-      
-       &Version;
-       &Description;
-      
-     
-     
-      
-       7.0.0
-       
-        Adicionado o parâmetro opcional levels.
-       
-      
-     
-    
-   
-  
- 
-
  
   &reftitle.examples;
   
diff --git a/reference/info/functions/getrusage.xml b/reference/info/functions/getrusage.xml
index 0c429e2be..50b756379 100644
--- a/reference/info/functions/getrusage.xml
+++ b/reference/info/functions/getrusage.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   getrusage
@@ -44,30 +44,6 @@
   
  
 
- 
-  &reftitle.changelog;
-  
-   
-    
-     
-      
-       &Version;
-       &Description;
-      
-     
-     
-      
-       7.0.0
-       
-        Esta função agora é suportada no Windows.
-       
-      
-     
-    
-   
-  
- 
-
  
   &reftitle.examples;
   
diff --git a/reference/libxml/book.xml b/reference/libxml/book.xml
index 4882e8eb6..24d97fdb4 100644
--- a/reference/libxml/book.xml
+++ b/reference/libxml/book.xml
@@ -1,7 +1,7 @@
 
-
+
 
-
+
  
  libxml
 
diff --git a/reference/libxml/functions/libxml-set-streams-context.xml b/reference/libxml/functions/libxml-set-streams-context.xml
index 52a02ad73..fa679c98e 100755
--- a/reference/libxml/functions/libxml-set-streams-context.xml
+++ b/reference/libxml/functions/libxml-set-streams-context.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   libxml_set_streams_context
@@ -80,10 +80,9 @@
   
    
     Um exemplo de <function>libxml_set_streams_context</function>
-    
+    
  array(
         'user_agent' => 'PHP libxml agent',
@@ -94,8 +93,8 @@ $context = stream_context_create($opts);
 libxml_set_streams_context($context);
 
 // solicita um arquivo por HTTP
-$doc = DOMDocument::load('http://www.example.com/file.xml');
-
+$dom = new DOMDocument;
+$doc = $dom->load('http://www.example.com/file.xml');
 ?>
 ]]>
     
diff --git a/reference/mbstring/book.xml b/reference/mbstring/book.xml
index 7404559ae..a2cdca459 100644
--- a/reference/mbstring/book.xml
+++ b/reference/mbstring/book.xml
@@ -1,7 +1,7 @@
 
-
+
 
-
+
  
  String Multibyte
 
diff --git a/reference/mbstring/functions/mb-convert-case.xml b/reference/mbstring/functions/mb-convert-case.xml
index c279da528..f92bcd3fd 100644
--- a/reference/mbstring/functions/mb-convert-case.xml
+++ b/reference/mbstring/functions/mb-convert-case.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   mb_convert_case
@@ -116,9 +116,9 @@
 
 ]]>
     
@@ -133,9 +133,9 @@ echo $str; // Prints Mary Had A Little Lamb And She Loved It So
 
 ]]>
     
diff --git a/reference/mbstring/functions/mb-convert-encoding.xml b/reference/mbstring/functions/mb-convert-encoding.xml
index 40151bd1c..bd27c6476 100644
--- a/reference/mbstring/functions/mb-convert-encoding.xml
+++ b/reference/mbstring/functions/mb-convert-encoding.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   mb_convert_encoding
@@ -144,7 +144,7 @@
   
    
     Exemplo de <function>mb_convert_encoding</function>
-    
+    
 
-
+
 
  
   mb_decode_numericentity
@@ -104,7 +104,7 @@
   
    
     Exemplo de <parameter>map</parameter>
-    
+    
 
-
+
 
  
   mb_encode_numericentity
@@ -106,8 +106,8 @@
   &reftitle.examples;
   
    
-    <parameter>map</parameter> example
-    
+    Exemplo de <parameter>map</parameter>
+    
 
-
+
 
  
   define
@@ -42,10 +42,7 @@
      value
      
       
-       O valor da constante. No PHP 5, value precisa ser
-       um valor do tipo scalar (int,
-       float, string, bool ou
-       &null;). No PHP 7, valores do tipo array também são aceitos.
+       O valor da constante.
       
       
        
@@ -101,6 +98,12 @@
       
      
      
+      
+       8.1.0
+       
+        value agora pode ser um objeto.
+       
+      
       
        8.0.0
        
@@ -113,12 +116,6 @@
         case_insensitive foi descontinuado e será removido na versão 8.0.0.
        
       
-      
-       7.0.0
-       
-        Valores do tipo array são permitidos.
-       
-      
      
     
    
diff --git a/reference/pcre/book.xml b/reference/pcre/book.xml
index cb99f893c..1bda91ff9 100644
--- a/reference/pcre/book.xml
+++ b/reference/pcre/book.xml
@@ -1,7 +1,7 @@
 
-
+
 
-
+
  
  Expressões Regulares (Compatíveis com Perl)
  PCRE
diff --git a/reference/pcre/functions/preg-grep.xml b/reference/pcre/functions/preg-grep.xml
index 7f0deb006..f4581aa85 100644
--- a/reference/pcre/functions/preg-grep.xml
+++ b/reference/pcre/functions/preg-grep.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   preg_grep
@@ -76,9 +76,12 @@
     
 
 ]]>
     
diff --git a/reference/pcre/functions/preg-match.xml b/reference/pcre/functions/preg-match.xml
index c7f97c21f..cce5017e1 100644
--- a/reference/pcre/functions/preg-match.xml
+++ b/reference/pcre/functions/preg-match.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   preg_match
@@ -316,6 +316,8 @@ if (preg_match("/\bweb\b/i", "PHP is the web scripting language of choice.")) {
     echo "Uma correspondência foi encontrada.";
 }
 
+echo "\n";
+
 if (preg_match("/\bweb\b/i", "PHP is the website scripting language of choice.")) {
     echo "Uma correspondência foi encontrada.";
 } else {
diff --git a/reference/pcre/functions/preg-replace-callback.xml b/reference/pcre/functions/preg-replace-callback.xml
index b7dc637e0..bf39201fc 100644
--- a/reference/pcre/functions/preg-replace-callback.xml
+++ b/reference/pcre/functions/preg-replace-callback.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   preg_replace_callback
@@ -67,7 +67,7 @@
        
         <function>preg_replace_callback</function> e
          função anônima
-        
+        
 
-
+
 
  
   preg_replace
@@ -214,6 +214,15 @@ The bear black slow jumped over the lazy dog.
     
 
-
+
 
-
+
  
  SimpleXML
 
diff --git a/reference/simplexml/examples.xml b/reference/simplexml/examples.xml
index 3ba169cf7..9d5dce883 100644
--- a/reference/simplexml/examples.xml
+++ b/reference/simplexml/examples.xml
@@ -1,5 +1,5 @@
 
-
+
 
 
  &reftitle.examples;
@@ -14,7 +14,7 @@
   
   
    
-    Inclusão do arquivo exemplo.php com string XML
+    Inclusão do arquivo examples/simplexml-data.php com string XML
     
 
 filme[0]->resumo;
     
 
 
 filme[0]->classificacao as $classificacao) {
     
 
 Usando XPath
     
      SimpleXML inclui suporte interno a XPath.
-     Para encontrar todos os elementos <personagem>:
+     Para encontrar todos os elementos <personagem>.
+    
+    
+     '//' serve como um corginga. Para especificar caminhos
+     absolutos, omita uma das barras:
     
     
 xpath('//personagem') as $personagem) {
 ?>
 ]]>
     
-    
-     '//' serve como um coringa. Para especificar caminhos
-     absolutos, basta omitir uma das barras.
-    
     &example.outputs;
     
 
 filme[0]->personagens->personagem[0]->nome = 'Senhorita Codificadora';
@@ -333,7 +333,7 @@ echo $filmes->asXML();
     
 filme[0]->personagens->addChild('personagem');
diff --git a/reference/simplexml/functions/simplexml-load-file.xml b/reference/simplexml/functions/simplexml-load-file.xml
index d68c76c40..aa6da50bf 100644
--- a/reference/simplexml/functions/simplexml-load-file.xml
+++ b/reference/simplexml/functions/simplexml-load-file.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   simplexml_load_file
@@ -104,15 +104,15 @@
     
 
 ]]>
@@ -124,7 +124,7 @@ if (file_exists('test.xml')) {
  Example Title
+  [book] => Array
   ...
 )
 ]]>
diff --git a/reference/simplexml/simplexmlelement/addAttribute.xml b/reference/simplexml/simplexmlelement/addAttribute.xml
index c64fcb75b..7f18db319 100644
--- a/reference/simplexml/simplexmlelement/addAttribute.xml
+++ b/reference/simplexml/simplexmlelement/addAttribute.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   SimpleXMLElement::addAttribute
@@ -64,7 +64,7 @@
   
    
     
-     Os exemplos listados podem incluir o arquivo exemplo.php,
+     Os exemplos listados podem incluir o arquivo examples/simplexml-data.php,
      que referem-se a uma string XML encontrada no primeiro exemplo
      do guia de uso básico.
     
@@ -75,7 +75,7 @@
 addAttribute('tipo', 'documentário');
diff --git a/reference/simplexml/simplexmlelement/addChild.xml b/reference/simplexml/simplexmlelement/addChild.xml
index 72df30180..4046cfc1e 100644
--- a/reference/simplexml/simplexmlelement/addChild.xml
+++ b/reference/simplexml/simplexmlelement/addChild.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   SimpleXMLElement::addChild
@@ -65,7 +65,7 @@
   
    
     
-     Os exemplos listados podem incluir o arquivo exemplo.php,
+     Os exemplos listados podem incluir o arquivo examples/simplexml-data.php,
      que referem-se a uma string XML encontrada no primeiro exemplo
      do guia de uso básico.
     
@@ -76,7 +76,7 @@
 examples/simplexml-data.php';
 
 $sxe = new SimpleXMLElement($xmlstr);
 $sxe->addAttribute('tipo', 'documentário');
diff --git a/reference/simplexml/simplexmlelement/asXML.xml b/reference/simplexml/simplexmlelement/asXML.xml
index edb6a33bf..53bb741a3 100644
--- a/reference/simplexml/simplexmlelement/asXML.xml
+++ b/reference/simplexml/simplexmlelement/asXML.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   SimpleXMLElement::asXML
@@ -119,7 +119,19 @@ echo $xml->asXML(); // textstuff ...
     
 
+ 
+  text
+  stuff
+ 
+ 
+  code
+ 
+
+XML;
+
+$xml = new SimpleXMLElement($string);
 
 /* Pesquisa por  */
 $result = $xml->xpath('/a/b/c');
diff --git a/reference/simplexml/simplexmlelement/construct.xml b/reference/simplexml/simplexmlelement/construct.xml
index c1c6dad79..facc33339 100644
--- a/reference/simplexml/simplexmlelement/construct.xml
+++ b/reference/simplexml/simplexmlelement/construct.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   SimpleXMLElement::__construct
@@ -103,7 +103,7 @@
   
    
     
-     Os exemplos listados podem incluir o arquivo exemplo.php,
+     Os exemplos listados podem incluir o arquivo examples/simplexml-data.php,
      que referem-se a uma string XML encontrada no primeiro exemplo
      do guia de uso básico.
     
@@ -114,7 +114,7 @@
 filme[0]->titulo;
diff --git a/reference/simplexml/simplexmlelement/getName.xml b/reference/simplexml/simplexmlelement/getName.xml
index 522b0dc9e..cf0fef141 100644
--- a/reference/simplexml/simplexmlelement/getName.xml
+++ b/reference/simplexml/simplexmlelement/getName.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   SimpleXMLElement::getName
@@ -34,7 +34,7 @@
   
    
     
-     Os exemplos listados podem incluir o arquivo exemplo.php,
+     Os exemplos listados podem incluir o arquivo examples/simplexml-data.php,
      que referem-se a uma string XML encontrada no primeiro exemplo
      do guia de uso básico.
     
@@ -44,7 +44,7 @@
     
 getName() . "\n";
diff --git a/reference/simplexml/simplexmlelement/key.xml b/reference/simplexml/simplexmlelement/key.xml
index 36afc31ae..8be4bb6cf 100644
--- a/reference/simplexml/simplexmlelement/key.xml
+++ b/reference/simplexml/simplexmlelement/key.xml
@@ -1,5 +1,5 @@
 
-
+
 
  
   SimpleXMLElement::key
@@ -78,7 +78,12 @@
 PHP BásicoXML Básico');
 
-echo var_dump($xmlElement->key());
+try {
+    echo var_dump($xmlElement->key());
+} catch (Error $e) {
+    echo $e->getMessage(), "\n";
+}
+
 $xmlElement->rewind(); // retrocede ao primeiro elemento
 echo var_dump($xmlElement->key());
 
@@ -88,7 +93,7 @@ echo var_dump($xmlElement->key());
      &example.outputs;
     
 
     
diff --git a/reference/xml/book.xml b/reference/xml/book.xml
index 8c26f0f41..41be17465 100644
--- a/reference/xml/book.xml
+++ b/reference/xml/book.xml
@@ -1,7 +1,7 @@
 
-
+
 
-
+
  
  Analisador de XML
 
diff --git a/reference/xml/examples.xml b/reference/xml/examples.xml
index 790b120d9..7464593f6 100644
--- a/reference/xml/examples.xml
+++ b/reference/xml/examples.xml
@@ -1,5 +1,5 @@
 
-
+
 
  &reftitle.examples;
  
@@ -12,7 +12,7 @@ "B", "EMPHASIS" => "I", @@ -135,7 +135,7 @@ xml_parser_free($xml_parser); Exemplo de Entidade Externa - +
+ +
+ Interpretando XML Com Classes + + Este exemplo mostra como usar uma classe com manipuladores. + + Mostrando a Estrutura de Elemento XML + +fp = fopen($file, 'r'))) { + throw new RunTimeException("could not open XML file '{$file}'"); + } + + $this->parser = xml_parser_create(); + + xml_set_element_handler($this->parser, self::startElement(...), self::endElement(...)); + xml_set_character_data_handler($this->parser, self::cdata(...)); + } + + private function startElement($parser, $name, $attrs) + { + for ($i = 0; $i < $this->depth; $i++) { + echo " "; + } + echo "$name\n"; + $this->depth++; + } + + private function endElement($parser, $name) + { + $this->depth--; + } + + private function cdata($parse, $cdata) + { + if (trim($cdata) === '') { + return; + } + for ($i = 0; $i < $this->depth; $i++) { + echo " "; + } + echo trim($cdata), "\n"; + } + + public function parse() + { + while ($data = fread($this->fp, 4096)) { + if (!xml_parse($this->parser, $data, feof($this->fp))) { + throw new RunTimeException( + sprintf( + "Erro XML: %s at line %d", + xml_error_string(xml_get_error_code($this->parser)), + xml_get_current_line_number($this->parser) + ) + ); + } + } + } +} + +$xmlParser = new CustomXMLParser($file); +$xmlParser->parse(); +?> +]]> + + + +
+
+ xml_parse @@ -106,13 +106,19 @@