mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-23 22:52:12 +01:00
sync with en rev
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- EN-Revision: f9dabdea3f92ea77cf5077020a3e945951fdc9db Maintainer: ae Status: ready --><!-- CREDITS: narigone,ae,felipe,leonardolara -->
|
||||
<chapter xml:id="language.oop5" xmlns="http://docbook.org/ns/docbook">
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: ae Status: ready --><!-- CREDITS: narigone,ae,felipe,leonardolara -->
|
||||
<chapter xml:id="language.oop5" xmlns="http://docbook.org/ns/docbook" annotations="interactive">
|
||||
<title>Classes e Objetos</title>
|
||||
|
||||
<sect1 xml:id="oop5.intro">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 984188eb6941dc419f49eed6c1a55a6b749a823d Maintainer: ae Status: ready --><!-- CREDITS: narigone,ae,fabioluciano,geekcom,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: narigone,ae,fabioluciano,geekcom,leonardolara -->
|
||||
<sect1 xml:id="language.oop5.abstract" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Abstração de Classes</title>
|
||||
|
||||
@@ -194,8 +194,8 @@ class C extends A
|
||||
mas deve ter <literal>get</literal> ou <literal>set</literal> declarado, mas não definido (como no exemplo acima).
|
||||
</simpara>
|
||||
<example>
|
||||
<title>Exemplo de propriedade abstrata</title>
|
||||
<programlisting role="php">
|
||||
<title>Exemplo de propriedade abstrata com ganchos</title>
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: a058684525563674d49fcfce7ce22d1183ee0a31 Maintainer: lhsazevedo Status: ready --><!-- CREDITS: fabioluciano,geekcom,lhsazevedo -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: fabioluciano,geekcom,lhsazevedo,leonardolara -->
|
||||
<sect1 xml:id="language.oop5.anonymous" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Classes anônimas</title>
|
||||
|
||||
@@ -185,9 +185,8 @@ class@anonymous/in/oNi1A0x7f8636ad2021
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// Usando uma classe anônima
|
||||
$util->setLogger(new readonly class('[DEBUG]') {
|
||||
var_dump(new readonly class('[DEBUG]') {
|
||||
public function __construct(private string $prefix)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- EN-Revision: 22583751fbfdaa3eaa41aeb6470d1343f5cb2c78 Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe, amandavale, machado, fabioluciano, lhsazevedo, leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe, amandavale, machado, fabioluciano, lhsazevedo, leonardolara -->
|
||||
<sect1 xml:id="language.oop5.autoload" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Autocarregamento de Classes</title>
|
||||
<para>
|
||||
@@ -44,7 +44,7 @@
|
||||
e <literal>MyClass2</literal> dos arquivos <filename>MyClass1.php</filename>
|
||||
e <filename>MyClass2.php</filename>, respectivamente.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
spl_autoload_register(function ($class_name) {
|
||||
@@ -90,7 +90,7 @@ Fatal error: Interface 'ITest' not found in ...
|
||||
pelo Composer. Ao incluir este arquivo, esses pacotes podem ser usados sem
|
||||
nenhum trabalho adicional.
|
||||
</simpara>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 2f85d57a0b5a01b875cbca2b291f04389cf61ac2 Maintainer: ae Status: ready --><!-- CREDITS: ae,amandavale,narigone,fabioluciano,lhsazevedo,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: ae,amandavale,narigone,fabioluciano,lhsazevedo,leonardolara -->
|
||||
|
||||
<sect1 xml:id="language.oop5.basic" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>O básico</title>
|
||||
@@ -224,11 +224,16 @@ readonly class Foo
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class SimpleClass {
|
||||
}
|
||||
|
||||
$instance = new SimpleClass();
|
||||
var_dump($instance);
|
||||
|
||||
// Também pode ser feito com uma variável:
|
||||
$className = 'SimpleClass';
|
||||
$instance = new $className(); // new SimpleClass()
|
||||
var_dump($instance);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -296,6 +301,9 @@ object(ClasseD)#1 (0) {
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class SimpleClass {
|
||||
public string $var;
|
||||
}
|
||||
|
||||
$instance = new SimpleClass();
|
||||
|
||||
@@ -375,16 +383,18 @@ bool(true)
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
echo (new DateTime())->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;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
2016
|
||||
2025
|
||||
2025
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
@@ -498,6 +508,14 @@ echo ($obj->bar)(), PHP_EOL;
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class SimpleClass
|
||||
{
|
||||
function displayVar()
|
||||
{
|
||||
echo "Parent class\n";
|
||||
}
|
||||
}
|
||||
|
||||
class ExtendClass extends SimpleClass
|
||||
{
|
||||
// Redefine o método pai
|
||||
@@ -757,9 +775,10 @@ Does\Not\Exist
|
||||
namespace NS {
|
||||
class ClassName {
|
||||
}
|
||||
|
||||
$c = new ClassName();
|
||||
print $c::class;
|
||||
}
|
||||
$c = new ClassName();
|
||||
print $c::class;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -788,7 +807,7 @@ NS\ClassName
|
||||
<para>
|
||||
<example>
|
||||
<title>Operador nullsafe</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 376d3f9c2ef7fcd64d8b8503d552013acefb8b5b Maintainer: ae Status: ready --><!-- CREDITS: narigone,felipe,ae,fabioluciano -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: narigone,felipe,ae,fabioluciano,leonardolara -->
|
||||
<sect1 xml:id="language.oop5.decon" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Construtores e Destrutores</title>
|
||||
|
||||
@@ -193,7 +193,7 @@ class Point {
|
||||
</note>
|
||||
<example>
|
||||
<title>New em inicializações</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
@@ -236,6 +236,9 @@ function test(
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$some_json_string = '{ "id": 1004, "name": "Elephpant" }';
|
||||
$some_xml_string = "<animal><id>1005</id><name>Elephpant</name></animal>";
|
||||
|
||||
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);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 2ab7e9d763666526942ed4477c4f876beb160892 Maintainer: fabioluciano Status: ready --><!-- CREDITS: ae,narigone,amandavale,fabioluciano -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: ae,narigone,amandavale,fabioluciano,leonardolara -->
|
||||
<sect1 xml:id="language.oop5.overloading" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Sobrecarga</title>
|
||||
|
||||
@@ -186,8 +186,6 @@ class PropertyTest
|
||||
}
|
||||
|
||||
|
||||
echo "<pre>\n";
|
||||
|
||||
$obj = new PropertyTest;
|
||||
|
||||
$obj->a = 1;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- EN-Revision: e3d36be7d64f1fd47612a91297c7f6d75e4e50c7 Maintainer: ae Status: ready --><!-- CREDITS: narigone,felipe,ae,fabioluciano,ABDALAZARD,leonardolara -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: narigone,felipe,ae,fabioluciano,ABDALAZARD,leonardolara -->
|
||||
<sect1 xml:id="language.oop5.paamayim-nekudotayim" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Operador de Resolução de Escopo (::)</title>
|
||||
|
||||
@@ -61,6 +61,10 @@ echo MyClass::CONST_VALUE;
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class MyClass {
|
||||
const CONST_VALUE = 'Um valor constante';
|
||||
}
|
||||
|
||||
class OtherClass extends MyClass
|
||||
{
|
||||
public static $my_static = 'variável estática';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 587de79705fc40682fa678296b4e42cbdc55314a Maintainer: ae Status: ready --><!-- CREDITS: fabioluciano, ae, vinelouzada, leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fabioluciano, ae, vinelouzada, leonardolara -->
|
||||
<sect1 xml:id="language.oop5.properties" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Propriedades</title>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<para>
|
||||
<example>
|
||||
<title>Declaração de propriedades</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class SimpleClass
|
||||
@@ -201,7 +201,7 @@ Fatal error: Uncaught Error: Typed property Forma::$numeroDeLados must not be ac
|
||||
explicitamente, se desejado.
|
||||
<example>
|
||||
<title>Exemplo de propriedade somente leitura</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
@@ -241,7 +241,7 @@ $test->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 <classname>Error</classname>.
|
||||
<example>
|
||||
<title>Inicilização ilegal de propriedades somente leitura.</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Test1 {
|
||||
@@ -261,7 +261,7 @@ $test1->prop = "foobar";
|
||||
<para>
|
||||
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.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
@@ -283,7 +283,7 @@ class Test {
|
||||
<para>
|
||||
Nenhum tipo de modificação é permitido, e o seguintes casos resultarão em um <classname>Error</classname>:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
@@ -312,7 +312,7 @@ foreach ($test as &$prop);
|
||||
<para>
|
||||
Entretanto, propriedades somente leitura não proíbem mutação. Objetos ou recursos armazenados em propriedades somente leitura ainda podem ser modificados internamente:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 617cc59b5902de0cadd32883b72b113bf62cf1b6 Maintainer: leonardolara Status: ready -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready -->
|
||||
<sect1 xml:id="language.oop5.property-hooks" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Ganchos de Propriedade</title>
|
||||
|
||||
@@ -220,6 +220,7 @@ class Example
|
||||
</simpara>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Example
|
||||
{
|
||||
public function __construct(
|
||||
@@ -241,6 +242,7 @@ class Example
|
||||
</simpara>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Example
|
||||
{
|
||||
public private(set) DateTimeInterface $created {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: b5f0c19bec9f70f1cbdc1480b3f3c92c608489d1 Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara -->
|
||||
<sect1 xml:id="language.oop5.traits" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Traits</title>
|
||||
<para>
|
||||
@@ -220,7 +220,7 @@ Hello World!
|
||||
para perrmitir o uso da implementação bigTalk da Trait B sob um apelido adicional
|
||||
<literal>talk</literal>.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
trait A {
|
||||
@@ -269,7 +269,7 @@ class Aliased_Talker {
|
||||
</para>
|
||||
<example xml:id="language.oop5.traits.visibility.ex1">
|
||||
<title>Exemplo de Mudança de Visibilidade de Método</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
trait HelloWorld {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: bda37a3a4dd7934642918455408d36b664e43a27 Maintainer: ae Status: ready --><!-- CREDITS: narigone,felipe,ae,fabioluciano,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: narigone,felipe,ae,fabioluciano,leonardolara -->
|
||||
<sect1 xml:id="language.oop5.visibility" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Visibilidade</title>
|
||||
<para>
|
||||
@@ -22,7 +22,7 @@
|
||||
</para>
|
||||
<example>
|
||||
<title>Declaração de propriedade</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ $obj2->imprimeAlo(); // Mostra Public, Protected2, Undefined
|
||||
</simpara>
|
||||
<example>
|
||||
<title>Visibilidade de propriedade assimétrica</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Book
|
||||
@@ -182,7 +182,7 @@ $b->pubYear = 2023; // Erro fatal
|
||||
</simpara>
|
||||
<example>
|
||||
<title>Herança de propriedade assimétrica</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Book
|
||||
@@ -214,7 +214,7 @@ class SpecialBook extends Book
|
||||
</para>
|
||||
<example>
|
||||
<title>Declaração de método</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/**
|
||||
@@ -313,7 +313,7 @@ $myFoo->test(); // Bar::testPrivate
|
||||
</para>
|
||||
<example>
|
||||
<title>Declaração de constantes (desde o PHP 7.1.0)</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/**
|
||||
@@ -378,7 +378,7 @@ $myclass2->foo2(); // Public e Protected funcionam, mas não Private
|
||||
</para>
|
||||
<example>
|
||||
<title>Acessando membros privados entre objetos do mesmo tipo</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Test
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 8aa5f18461de969e5131fbed3a95c365420e571a Maintainer: ae Status: ready --><!-- CREDITS: marabesi,ae,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: marabesi,ae,leonardolara -->
|
||||
|
||||
<book xml:id="book.dom" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.dom" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundledexternal" ?>
|
||||
<title>Document Object Model</title>
|
||||
<titleabbrev>DOM</titleabbrev>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- EN-Revision: 2c9920402e11ecdc75f604e0d23c23fab1c75b74 Maintainer: leonardolara Status: ready -->
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready -->
|
||||
<refentry xml:id="dom-attr.isid" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<refnamediv>
|
||||
<refname>Dom\Attr::isId</refname>
|
||||
@@ -40,7 +40,7 @@
|
||||
<?php
|
||||
|
||||
// É necessário validar o documento antes de referir ao seu id
|
||||
$doc = Dom\XMLDocument::createFromFile('book.xml', LIBXML_DTDVALID);
|
||||
$doc = Dom\XMLDocument::createFromFile('examples/book-docbook.xml', LIBXML_DTDVALID);
|
||||
|
||||
// Recuperando o atributo denominado id do elemento chapter
|
||||
$attr = $doc->getElementsByTagName('chapter')->item(0)->getAttributeNode('id');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 4f5e2b22575131fa5e9c3004b1c874e1acb06573 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<refentry xml:id="domattr.construct" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>DOMAttr::__construct</refname>
|
||||
@@ -52,7 +52,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$dom = new DOMDocument('1.0', 'iso-8859-1');
|
||||
$dom = new DOMDocument('1.0', 'utf-8');
|
||||
$element = $dom->appendChild(new DOMElement('root'));
|
||||
$attr = $element->setAttributeNode(new DOMAttr('attr', 'attrvalue'));
|
||||
echo $dom->saveXML();
|
||||
@@ -64,7 +64,7 @@ echo $dom->saveXML();
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root attr="attrvalue" />
|
||||
<root attr="attrvalue"/>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 2c9920402e11ecdc75f604e0d23c23fab1c75b74 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<refentry xml:id="domattr.isid" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>DOMAttr::isId</refname>
|
||||
@@ -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');
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 7b1704c9a9d3100e85b47568cb0f06ee2122db08 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<refentry xml:id="domdocument.adoptnode" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument::adoptNode</refname>
|
||||
@@ -72,7 +71,7 @@ $doc2 = new DOMDocument;
|
||||
$doc2->loadXML("<root/>");
|
||||
$doc2->documentElement->appendChild($doc2->adoptNode($hello));
|
||||
|
||||
echo $doc1->saveXML() . PHP_EOL;
|
||||
echo $doc1->saveXML() . PHP_EOL . PHP_EOL;
|
||||
echo $doc2->saveXML();
|
||||
?>
|
||||
]]>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 4f5e2b22575131fa5e9c3004b1c874e1acb06573 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<refentry xml:id="domdocument.getelementbyid" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument::getElementById</refname>
|
||||
@@ -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;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
The element whose id is 'php-basics' is: book
|
||||
O elemento cujo ID é 'php-basics' é: book
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 765749a26b620538117fff4425fafb3ed5834b54 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<refentry xml:id="domdocument.load" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument::load</refname>
|
||||
@@ -103,7 +103,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument();
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book.xml');
|
||||
echo $doc->saveXML();
|
||||
?>
|
||||
]]>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: c1349f9574ed77c268c6312a07466f06d59e5078 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<refentry xml:id="domdocument.replacechildren" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument::replaceChildren</refname>
|
||||
@@ -27,7 +26,7 @@
|
||||
<example xml:id="domdocument.replacechildren.example.basic">
|
||||
<title>Exemplo de <methodname>DOMDocument::replaceChildren</methodname></title>
|
||||
<para>
|
||||
Substitui os filhos por novos nodes.
|
||||
Substitui os filhos por novos nós.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
@@ -35,7 +34,7 @@
|
||||
$doc = new DOMDocument;
|
||||
$doc->loadXML("<container><hello/></container>");
|
||||
|
||||
$doc->replaceWith("beautiful", $doc->createElement("world"));
|
||||
$doc->replaceChildren("beautiful", $doc->createElement("world"));
|
||||
|
||||
echo $doc->saveXML();
|
||||
?>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 4f5e2b22575131fa5e9c3004b1c874e1acb06573 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<refentry xml:id="domdocument.validate" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument::validate</refname>
|
||||
@@ -43,7 +43,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
$dom = new DOMDocument;
|
||||
$dom->load('book.xml');
|
||||
$dom->load('examples/book.xml');
|
||||
if ($dom->validate()) {
|
||||
echo "Este documento é válido!\n";
|
||||
}
|
||||
@@ -58,7 +58,7 @@ if ($dom->validate()) {
|
||||
<?php
|
||||
$dom = new DOMDocument;
|
||||
$dom->validateOnParse = true;
|
||||
$dom->load('book.xml');
|
||||
$dom->load('examples/book.xml');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: d2939d46110158f98ace5c20761c808b04c905d8 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<refentry xml:id="domdocument.xinclude" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument::xinclude</refname>
|
||||
@@ -57,7 +57,7 @@ $xml = <<<EOD
|
||||
<chapter xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>Books of the other guy..</title>
|
||||
<para>
|
||||
<xi:include href="book.xml">
|
||||
<xi:include href="examples/book.xml">
|
||||
<xi:fallback>
|
||||
<error>xinclude: book.xml not found</error>
|
||||
</xi:fallback>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: c1349f9574ed77c268c6312a07466f06d59e5078 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<refentry xml:id="domdocumentfragment.replacechildren" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<refnamediv>
|
||||
<refname>DOMDocumentFragment::replaceChildren</refname>
|
||||
@@ -37,7 +36,7 @@ $doc->loadXML("<container><hello/></container>");
|
||||
$fragment = $doc->createDocumentFragment();
|
||||
$fragment->append("hello");
|
||||
|
||||
$fragment->replaceWith("beautiful", $doc->createElement("world"));
|
||||
$fragment->replaceChildren("beautiful", $doc->createElement("world"));
|
||||
|
||||
echo $doc->saveXML($fragment);
|
||||
?>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: f86cc1c4bb04f50baf4764d7616a819fe6ca840f Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<refentry xml:id="domnamednodemap.getnameditem" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>DOMNamedNodeMap::getNamedItem</refname>
|
||||
@@ -46,12 +46,10 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
|
||||
$id = $doc->firstChild->attributes->getNamedItem('id');
|
||||
$doc->load('examples/book.xml');
|
||||
|
||||
$id = $doc->firstChild->nextSibling->nextSibling->firstChild->nextSibling->attributes->getNamedItem('id');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -61,9 +59,11 @@ $id = $doc->firstChild->attributes->getNamedItem('id');
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('examples/book.xml');
|
||||
|
||||
$id = $doc->firstChild->attributes['id'];
|
||||
|
||||
$id = $doc->firstChild->nextSibling->nextSibling->firstChild->nextSibling->attributes['id'];
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 6f103ee118aacbde15fc894eda6f3ce961548ceb Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto, leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto, leonardolara -->
|
||||
<refentry xml:id="domnode.removechild" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>DOMNode::removeChild</refname>
|
||||
@@ -72,7 +72,7 @@
|
||||
<?php
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-docbook.xml');
|
||||
|
||||
$book = $doc->documentElement;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: f86cc1c4bb04f50baf4764d7616a819fe6ca840f Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<refentry xml:id="domnodelist.item" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>DOMNodeList::item</refname>
|
||||
@@ -56,16 +56,14 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->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";
|
||||
}
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -75,6 +73,10 @@ for ($i = 0; $i < $items->length; $i++) {
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->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++) {
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('examples/book-docbook.xml');
|
||||
|
||||
$items = $doc->getElementsByTagName('entry');
|
||||
|
||||
foreach ($items as $item) {
|
||||
echo $item->nodeValue . "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 01904e809eaf0aa60e7ce0524400ddd5681c9541 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<refentry xml:id="domxpath.evaluate" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<refnamediv>
|
||||
<refname>DOMXPath::evaluate</refname>
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
$doc = new DOMDocument;
|
||||
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-dcobook.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 01904e809eaf0aa60e7ce0524400ddd5681c9541 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<refentry xml:id="domxpath.query" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>DOMXPath::query</refname>
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: db4a10ffdc22db3b49ea7fc01c36d21180c339b8 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto, leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto, leonardolara -->
|
||||
<refentry xml:id="domxpath.registerphpfunctions" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>DOMXPath::registerPhpFunctions</refname>
|
||||
@@ -137,7 +137,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-simple.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
@@ -177,7 +177,7 @@ PHP Secrets by Jenny Smythe
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-simple.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
@@ -218,7 +218,7 @@ PHP Basics
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-simple.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 130701dd4e64351d38da565ab3043a8f795698f8 Maintainer: leonardolara Status: ready --><!-- CREDITS: diogo, rarruda, ae, leonardolara, thiago -->
|
||||
<!-- EN-Revision: 21cd3a942724400765125b657d24f8c8c4d623e9 Maintainer: leonardolara Status: ready --><!-- CREDITS: diogo, rarruda, ae, leonardolara, thiago -->
|
||||
<refentry xml:id="function.dirname" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>dirname</refname>
|
||||
@@ -103,30 +103,6 @@ dirname('C:\\'); // Retornará 'C:\' no Windows e '.' em sistemas *nix.
|
||||
</caution>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="changelog">
|
||||
&reftitle.changelog;
|
||||
<para>
|
||||
<informaltable>
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>&Version;</entry>
|
||||
<entry>&Description;</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>7.0.0</entry>
|
||||
<entry>
|
||||
Adicionado o parâmetro opcional <parameter>levels</parameter>.
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: e947f2e12b1e321d67f6560c5f2884e6d885858f Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara -->
|
||||
<!-- EN-Revision: a277389c9d2d5a940fcd6dbe62da7e109282379d Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara -->
|
||||
<refentry xml:id="function.getrusage" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>getrusage</refname>
|
||||
@@ -44,30 +44,6 @@
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="changelog">
|
||||
&reftitle.changelog;
|
||||
<para>
|
||||
<informaltable>
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>&Version;</entry>
|
||||
<entry>&Description;</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>7.0.0</entry>
|
||||
<entry>
|
||||
Esta função agora é suportada no Windows.
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: b72a6bf2e6cd37d1c36575e1e14ad667a3993d54 Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe,leonardolara -->
|
||||
|
||||
<book xml:id="book.libxml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.libxml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundledexternal" ?>
|
||||
<title>libxml</title>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 81bc2b5f454f893206009e0e931a72c85a86ac63 Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe,leonardolara -->
|
||||
<refentry xml:id="function.libxml-set-streams-context" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>libxml_set_streams_context</refname>
|
||||
@@ -80,10 +80,9 @@
|
||||
<para>
|
||||
<example>
|
||||
<title>Um exemplo de <function>libxml_set_streams_context</function></title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$opts = array(
|
||||
'http' => 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');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 740eb58e8c03cfc5ac98eda13943262775b73ff2 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
|
||||
<book xml:id="book.mbstring" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.mbstring" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundled" ?>
|
||||
<title>String Multibyte</title>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 398329d3c680e8eccd694a6a3f7fe1ebd929ea80 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto,leonardolara -->
|
||||
<refentry xml:id="function.mb-convert-case" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>mb_convert_case</refname>
|
||||
@@ -116,9 +116,9 @@
|
||||
<?php
|
||||
$str = "mary had a Little lamb and she loved it so";
|
||||
$str = mb_convert_case($str, MB_CASE_UPPER, "UTF-8");
|
||||
echo $str; // Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
|
||||
echo $str, PHP_EOL;
|
||||
$str = mb_convert_case($str, MB_CASE_TITLE, "UTF-8");
|
||||
echo $str; // Prints Mary Had A Little Lamb And She Loved It So
|
||||
echo $str, PHP_EOL;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -133,9 +133,9 @@ echo $str; // Prints Mary Had A Little Lamb And She Loved It So
|
||||
<?php
|
||||
$str = "Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
|
||||
$str = mb_convert_case($str, MB_CASE_UPPER, "UTF-8");
|
||||
echo $str; // Imprime ΤΆΧΙΣΤΗ ΑΛΏΠΗΞ ΒΑΦΉΣ ΨΗΜΈΝΗ ΓΗ, ΔΡΑΣΚΕΛΊΖΕΙ ΥΠΈΡ ΝΩΘΡΟΎ ΚΥΝΌΣ
|
||||
echo $str, PHP_EOL;
|
||||
$str = mb_convert_case($str, MB_CASE_TITLE, "UTF-8");
|
||||
echo $str; // Imprime Τάχιστη Αλώπηξ Βαφήσ Ψημένη Γη, Δρασκελίζει Υπέρ Νωθρού Κυνόσ
|
||||
echo $str, PHP_EOL;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 2c17cef6e71c3d85011319cde128cc4edf89a053 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<refentry xml:id="function.mb-convert-encoding" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>mb_convert_encoding</refname>
|
||||
@@ -144,7 +144,7 @@
|
||||
<para>
|
||||
<example>
|
||||
<title>Exemplo de <function>mb_convert_encoding</function></title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/* Converte a codificação interna para SJIS */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 22583751fbfdaa3eaa41aeb6470d1343f5cb2c78 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<refentry xml:id="function.mb-decode-numericentity" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>mb_decode_numericentity</refname>
|
||||
@@ -104,7 +104,7 @@
|
||||
<para>
|
||||
<example>
|
||||
<title>Exemplo de <parameter>map</parameter></title>
|
||||
<programlisting role="php">
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$convmap = array (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: d553fa36940639b0889ec4358fa3bbb92f123b69 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<refentry xml:id="function.mb-encode-numericentity" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>mb_encode_numericentity</refname>
|
||||
@@ -106,8 +106,8 @@
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><parameter>map</parameter> example</title>
|
||||
<programlisting role="php">
|
||||
<title>Exemplo de <parameter>map</parameter></title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$convmap = array (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: cdc9d28d334bbc08386fecf8aade66080004a9dd Maintainer: leonardolara Status: ready -->
|
||||
<!-- EN-Revision: e52b5c7312891f4728a2000583b7861a505b7ec9 Maintainer: leonardolara Status: ready -->
|
||||
<refentry xml:id="function.define" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>define</refname>
|
||||
@@ -42,10 +42,7 @@
|
||||
<term><parameter>value</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
O valor da constante. No PHP 5, <parameter>value</parameter> precisa ser
|
||||
um valor do tipo <type>scalar</type> (<type>int</type>,
|
||||
<type>float</type>, <type>string</type>, <type>bool</type> ou
|
||||
&null;). No PHP 7, valores do tipo <type>array</type> também são aceitos.
|
||||
O valor da constante.
|
||||
</para>
|
||||
<warning>
|
||||
<para>
|
||||
@@ -101,6 +98,12 @@
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>8.1.0</entry>
|
||||
<entry>
|
||||
<parameter>value</parameter> agora pode ser um objeto.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>8.0.0</entry>
|
||||
<entry>
|
||||
@@ -113,12 +116,6 @@
|
||||
<parameter>case_insensitive</parameter> foi descontinuado e será removido na versão 8.0.0.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>7.0.0</entry>
|
||||
<entry>
|
||||
Valores do tipo <type>array</type> são permitidos.
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 68c2c871505aadf983f16113c5b077b335ce8d76 Maintainer: ae Status: ready --><!-- CREDITS: felipe,ae,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe,ae,leonardolara -->
|
||||
|
||||
<book xml:id="book.pcre" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.pcre" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="core" ?>
|
||||
<title>Expressões Regulares (Compatíveis com Perl)</title>
|
||||
<titleabbrev>PCRE</titleabbrev>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 41c8533ff5a8f93ba9fdf0732d05dd5ab79864c9 Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara -->
|
||||
<refentry xml:id="function.preg-grep" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>preg_grep</refname>
|
||||
@@ -76,9 +76,12 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// retorna todos os elementos do array
|
||||
// contendo número em ponto flutuante
|
||||
$array = [ "4", M_PI, "2.74", 42 ];
|
||||
|
||||
// retorna todos os elementos do array contendo número em ponto flutuante
|
||||
$fl_array = preg_grep("/^(\d+)?\.\d+$/", $array);
|
||||
|
||||
var_dump($fl_array);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 41c8533ff5a8f93ba9fdf0732d05dd5ab79864c9 Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara -->
|
||||
<refentry xml:id="function.preg-match" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>preg_match</refname>
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 41c8533ff5a8f93ba9fdf0732d05dd5ab79864c9 Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe, adiel, felipe, leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe, adiel, felipe, leonardolara -->
|
||||
<refentry xml:id="function.preg-replace-callback" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>preg_replace_callback</refname>
|
||||
@@ -67,7 +67,7 @@
|
||||
<example>
|
||||
<title><function>preg_replace_callback</function> e
|
||||
função anônima</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/* um filtro de linha de comando em estilo Unix para converter maiúsculas
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 62126c55f1c6ed444043e7272c4f9e233818a44b Maintainer: leonardolara Status: ready --><!-- CREDITS: FelipeBarth, adiel, leonardolara -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: FelipeBarth, adiel, leonardolara -->
|
||||
<refentry xml:id="function.preg-replace" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>preg_replace</refname>
|
||||
@@ -214,6 +214,15 @@ The bear black slow jumped over the lazy dog.
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$string = 'The quick brown fox jumps over the lazy dog.';
|
||||
$patterns = array();
|
||||
$patterns[0] = '/quick/';
|
||||
$patterns[1] = '/brown/';
|
||||
$patterns[2] = '/fox/';
|
||||
$replacements = array();
|
||||
$replacements[2] = 'bear';
|
||||
$replacements[1] = 'black';
|
||||
$replacements[0] = 'slow';
|
||||
ksort($patterns);
|
||||
ksort($replacements);
|
||||
echo preg_replace($patterns, $replacements, $string);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- EN-Revision: 46a9cdd2dbef4ec89bf65fad9930e2feb78bbb98 Maintainer: fabioluciano Status: ready --><!-- CREDITS: felipe, rafael, fabioluciano -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe, rafael, fabioluciano -->
|
||||
|
||||
<book xml:id="book.simplexml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.simplexml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundledexternal" ?>
|
||||
<title>SimpleXML</title>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: a0ae28d3bc85f927c22649ebd9a590b921534b7d Maintainer: leonardolara Status: ready -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready -->
|
||||
|
||||
<chapter xml:id="simplexml.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
&reftitle.examples;
|
||||
@@ -14,7 +14,7 @@
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Inclusão do arquivo exemplo.php com string XML</title>
|
||||
<title>Inclusão do arquivo examples/simplexml-data.php com string XML</title>
|
||||
<programlisting role="php" xml:id="simplexml.examples.movie">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -59,7 +59,7 @@ XML;
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$filmes = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -88,7 +88,7 @@ echo $filmes->filme[0]->resumo;
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$filmes = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -114,7 +114,7 @@ O PHP resolve todos os meus problemas!
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$filmes = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -154,7 +154,7 @@ Sr. Codificador representado(a) por El Actór
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$filmes = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -192,7 +192,7 @@ foreach ($filmes->filme[0]->classificacao as $classificacao) {
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$filmes = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -222,7 +222,7 @@ Meu filme favorito. PHP: Nos Bastidores do Interpretador
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$filmes1 = new SimpleXMLElement($xmlstr);
|
||||
$filmes2 = new SimpleXMLElement($xmlstr);
|
||||
@@ -243,12 +243,16 @@ bool(false)
|
||||
<title>Usando XPath</title>
|
||||
<simpara>
|
||||
SimpleXML inclui suporte interno a <acronym>XPath</acronym>.
|
||||
Para encontrar todos os elementos <literal><personagem></literal>:
|
||||
Para encontrar todos os elementos <literal><personagem></literal>.
|
||||
</simpara>
|
||||
<simpara>
|
||||
'<literal>//</literal>' serve como um corginga. Para especificar caminhos
|
||||
absolutos, omita uma das barras:
|
||||
</simpara>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$filmes = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -258,10 +262,6 @@ foreach ($filmes->xpath('//personagem') as $personagem) {
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<simpara>
|
||||
'<literal>//</literal>' serve como um coringa. Para especificar caminhos
|
||||
absolutos, basta omitir uma das barras.
|
||||
</simpara>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -281,7 +281,7 @@ Sr. Codificador representado(a) por El Actór
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
$filmes = new SimpleXMLElement($xmlstr);
|
||||
|
||||
$filmes->filme[0]->personagens->personagem[0]->nome = 'Senhorita Codificadora';
|
||||
@@ -333,7 +333,7 @@ echo $filmes->asXML();
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
$filmes = new SimpleXMLElement($xmlstr);
|
||||
|
||||
$personagem = $filmes->filme[0]->personagens->addChild('personagem');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- EN-Revision: d2939d46110158f98ace5c20761c808b04c905d8 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: rafa, fabioluciano, fernandowobeto -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: rafa, fabioluciano, fernandowobeto -->
|
||||
<refentry xml:id="function.simplexml-load-file" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>simplexml_load_file</refname>
|
||||
@@ -104,15 +104,15 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// O arquivo test.xml contém um documento XML com um elemento root
|
||||
// O arquivo examples/book.xml contém um documento XML com um elemento root
|
||||
// e ao menos um elemento /[root]/title.
|
||||
|
||||
if (file_exists('test.xml')) {
|
||||
$xml = simplexml_load_file('test.xml');
|
||||
if (file_exists('examples/book.xml')) {
|
||||
$xml = simplexml_load_file('examples/book.xml');
|
||||
|
||||
print_r($xml);
|
||||
} else {
|
||||
exit('Falha ao abrir test.xml.');
|
||||
exit('Falha ao abrir examples/book.xml.');
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
@@ -124,7 +124,7 @@ if (file_exists('test.xml')) {
|
||||
<![CDATA[
|
||||
SimpleXMLElement Object
|
||||
(
|
||||
[title] => Example Title
|
||||
[book] => Array
|
||||
...
|
||||
)
|
||||
]]>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 770c6facae667218f69c8ea2715ea20f6fab32f3 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: rafael, fabioluciano, fernandowobeto, leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: rafael, fabioluciano, fernandowobeto, leonardolara -->
|
||||
<refentry xml:id="simplexmlelement.addattribute" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>SimpleXMLElement::addAttribute</refname>
|
||||
@@ -64,7 +64,7 @@
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
Os exemplos listados podem incluir o arquivo <literal>exemplo.php</literal>,
|
||||
Os exemplos listados podem incluir o arquivo <literal>examples/simplexml-data.php</literal>,
|
||||
que referem-se a uma string XML encontrada no primeiro exemplo
|
||||
do guia de <link linkend="simplexml.examples-basic">uso básico</link>.
|
||||
</para>
|
||||
@@ -75,7 +75,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$sxe = new SimpleXMLElement($xmlstr);
|
||||
$sxe->addAttribute('tipo', 'documentário');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 770c6facae667218f69c8ea2715ea20f6fab32f3 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: rafael, fabioluciano, fernandowobeto, leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: rafael, fabioluciano, fernandowobeto, leonardolara -->
|
||||
<refentry xml:id="simplexmlelement.addchild" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>SimpleXMLElement::addChild</refname>
|
||||
@@ -65,7 +65,7 @@
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
Os exemplos listados podem incluir o arquivo <literal>exemplo.php</literal>,
|
||||
Os exemplos listados podem incluir o arquivo <literal>examples/simplexml-data.php</literal>,
|
||||
que referem-se a uma string XML encontrada no primeiro exemplo
|
||||
do guia de <link linkend="simplexml.examples-basic">uso básico</link>.
|
||||
</para>
|
||||
@@ -76,7 +76,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
include 'exemplo.php';
|
||||
include '>examples/simplexml-data.php';
|
||||
|
||||
$sxe = new SimpleXMLElement($xmlstr);
|
||||
$sxe->addAttribute('tipo', 'documentário');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 770c6facae667218f69c8ea2715ea20f6fab32f3 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: rafael, fabioluciano, fernandowobeto -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready --><!-- CREDITS: rafael, fabioluciano, fernandowobeto -->
|
||||
<refentry xml:id="simplexmlelement.asxml" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>SimpleXMLElement::asXML</refname>
|
||||
@@ -119,7 +119,19 @@ echo $xml->asXML(); // <?xml ... <a><b><c>text</c><c>stuff</c> ...
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Continuação exemplo acima.
|
||||
$string = <<<XML
|
||||
<a>
|
||||
<b>
|
||||
<c>text</c>
|
||||
<c>stuff</c>
|
||||
</b>
|
||||
<d>
|
||||
<c>code</c>
|
||||
</d>
|
||||
</a>
|
||||
XML;
|
||||
|
||||
$xml = new SimpleXMLElement($string);
|
||||
|
||||
/* Pesquisa por <a><b><c> */
|
||||
$result = $xml->xpath('/a/b/c');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 28f0dc949d62c97698ac4a0ca814c3780d8cf318 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: amandavale, fabioluciano, fernandowobeto, leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: amandavale, fabioluciano, fernandowobeto, leonardolara -->
|
||||
<refentry xml:id="simplexmlelement.construct" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>SimpleXMLElement::__construct</refname>
|
||||
@@ -103,7 +103,7 @@
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
Os exemplos listados podem incluir o arquivo <literal>exemplo.php</literal>,
|
||||
Os exemplos listados podem incluir o arquivo <literal>examples/simplexml-data.php</literal>,
|
||||
que referem-se a uma string XML encontrada no primeiro exemplo
|
||||
do guia de <link linkend="simplexml.examples-basic">uso básico</link>.
|
||||
</para>
|
||||
@@ -114,7 +114,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$sxe = new SimpleXMLElement($xmlstr);
|
||||
echo $sxe->filme[0]->titulo;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 770c6facae667218f69c8ea2715ea20f6fab32f3 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: rafael, fabioluciano, fernandowobeto, leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: rafael, fabioluciano, fernandowobeto, leonardolara -->
|
||||
<refentry xml:id="simplexmlelement.getname" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>SimpleXMLElement::getName</refname>
|
||||
@@ -34,7 +34,7 @@
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
Os exemplos listados podem incluir o arquivo <literal>exemplo.php</literal>,
|
||||
Os exemplos listados podem incluir o arquivo <literal>examples/simplexml-data.php</literal>,
|
||||
que referem-se a uma string XML encontrada no primeiro exemplo
|
||||
do guia de <link linkend="simplexml.examples-basic">uso básico</link>.
|
||||
</para>
|
||||
@@ -44,7 +44,7 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'exemplo.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
$sxe = new SimpleXMLElement($xmlstr);
|
||||
|
||||
echo $sxe->getName() . "\n";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: dcb657b7e9e4f7622ce3394ae1fa3c14538721e1 Maintainer: leonardolara Status: ready -->
|
||||
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: leonardolara Status: ready -->
|
||||
<refentry xml:id="simplexmlelement.key" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>SimpleXMLElement::key</refname>
|
||||
@@ -78,7 +78,12 @@
|
||||
<?php
|
||||
$xmlElement = new SimpleXMLElement('<livros><livro>PHP Básico</livro><livro>XML Básico</livro></livros>');
|
||||
|
||||
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;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
Iterator not initialized or already consumed
|
||||
string(5) "livro"
|
||||
]]>
|
||||
</screen>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 5f8047c12b4078a6f686b2b0589e9284c47bf155 Maintainer: leonardolara Status: ready --><!-- CREDITS: surfmax,felipe,leonardolara -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: surfmax,felipe,leonardolara -->
|
||||
|
||||
<book xml:id="book.xml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.xml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundledexternal" ?>
|
||||
<title>Analisador de XML</title>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: f5992156e664c34794804c282a95f6428a2687a7 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<!-- EN-Revision: 802374deda550dfb866348d41a019315cb1f9840 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<chapter xml:id="xml.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
&reftitle.examples;
|
||||
<section xml:id="example.xml-structure">
|
||||
@@ -12,7 +12,7 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$file = "data.xml";
|
||||
$file = "examples/book.xml";
|
||||
$depth = 0;
|
||||
|
||||
function startElement($parser, $name, $attrs)
|
||||
@@ -67,7 +67,7 @@ xml_parser_free($xml_parser);
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$file = "data.xml";
|
||||
$file = "examples/book.xml";
|
||||
$map_array = array(
|
||||
"BOLD" => "B",
|
||||
"EMPHASIS" => "I",
|
||||
@@ -135,7 +135,7 @@ xml_parser_free($xml_parser);
|
||||
<para>
|
||||
<example>
|
||||
<title>Exemplo de Entidade Externa</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$file = "xmltest.xml";
|
||||
@@ -323,6 +323,86 @@ xml_parser_free($xml_parser);
|
||||
</example>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="example.xml-parsing-with-class">
|
||||
<title>Interpretando XML Com Classes</title>
|
||||
<para>
|
||||
Este exemplo mostra como usar uma classe com manipuladores.
|
||||
<example>
|
||||
<title>Mostrando a Estrutura de Elemento XML</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$file = "examples/book.xml";
|
||||
|
||||
class CustomXMLParser
|
||||
{
|
||||
private $fp;
|
||||
private $parser;
|
||||
private $depth = 0;
|
||||
|
||||
function __construct(string $file)
|
||||
{
|
||||
if (!($this->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();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
</chapter>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- EN-Revision: 3db49ee0a331a657dd97b539a749f53d3965b593 Maintainer: fernandowobeto Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto -->
|
||||
<refentry xml:id="function.xml-parse" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>xml_parse</refname>
|
||||
@@ -106,13 +106,19 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$stream = fopen('large.xml', 'r');
|
||||
$stream = fopen('examples/book-simple.xml', 'r');
|
||||
$parser = xml_parser_create();
|
||||
// configure os manipuladores aqui
|
||||
|
||||
xml_set_element_handler(
|
||||
$parser,
|
||||
function($parser, $name, $attributes) { echo $name, PHP_EOL; },
|
||||
function($parser, $name) { echo $name, PHP_EOL; }
|
||||
);
|
||||
|
||||
while (($data = fread($stream, 16384))) {
|
||||
xml_parse($parser, $data); // analise o pedaço atual
|
||||
xml_parse($parser, $data); // analisa o pedaço atual
|
||||
}
|
||||
xml_parse($parser, '', true); // finalize a análise
|
||||
xml_parse($parser, '', true); // finaliza a análise
|
||||
xml_parser_free($parser);
|
||||
fclose($stream);
|
||||
]]>
|
||||
|
||||
Reference in New Issue
Block a user