mirror of
https://github.com/php/doc-pl.git
synced 2026-03-25 15:42:11 +01:00
143 lines
3.5 KiB
XML
143 lines
3.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 4d17b7b4947e7819ff5036715dd706be87ae4def Maintainer: grzesiek Status: ready -->
|
|
<!-- $Revision$ -->
|
|
<reference xml:id="class.stdclass" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
|
|
<title>Klasa stdClass</title>
|
|
<titleabbrev>stdClass</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
<section xml:id="stdclass.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
Ogólna pusta klasa z dynamicznymi właściwościami.
|
|
</para>
|
|
|
|
<para>
|
|
Obiekty tej klasy mogą być tworzone za pomocą
|
|
operatora <link linkend="language.oop5.basic.new">new</link> lub tworzone przez
|
|
<link linkend="language.types.object.casting">rzutowanie do obiektu</link>.
|
|
Kilka funkcji PHP również tworzy instancje tej klasy, np.
|
|
<function>json_decode</function>, <function>mysqli_fetch_object</function>
|
|
lub <methodname>PDOStatement::fetchObject</methodname>.
|
|
</para>
|
|
|
|
<para>
|
|
Pomimo braku implementacji magicznych metod
|
|
<link linkend="object.get">__get()</link>/<link linkend="object.set">__set()</link>,
|
|
klasa ta pozwala na dynamiczne właściwości i nie wymaga atrybutu
|
|
<code>#[\AllowDynamicProperties]</code>.
|
|
</para>
|
|
|
|
<para>
|
|
Nie jest to klasa bazowa, ponieważ PHP nie posiada koncepcji uniwersalnej klasy bazowej.
|
|
Możliwe jest jednak utworzenie własnej klasy, która rozszerza klasę
|
|
<classname>stdClass</classname> i w rezultacie dziedziczy funkcjonalność
|
|
właściwości dynamicznych.
|
|
</para>
|
|
</section>
|
|
|
|
<section xml:id="stdclass.synopsis">
|
|
&reftitle.classsynopsis;
|
|
|
|
<classsynopsis class="class">
|
|
<ooclass>
|
|
<classname>stdClass</classname>
|
|
</ooclass>
|
|
</classsynopsis>
|
|
|
|
<para>
|
|
Klasa ta nie posiada żadnych metod ani domyślnych właściwości.
|
|
</para>
|
|
</section>
|
|
|
|
<section xml:id="stdclass.examples" role="examples">
|
|
&reftitle.examples;
|
|
<example xml:id="stdclass.basic-example">
|
|
<title>Utworzona w wyniku rzutowania typu na obiekt</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$obj = (object) array('foo' => 'bar');
|
|
var_dump($obj);
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
object(stdClass)#1 (1) {
|
|
["foo"]=>
|
|
string(3) "bar"
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
<example xml:id="stdclass.json-example">
|
|
<title>Created as a result of <function>json_decode</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$json = '{"foo":"bar"}';
|
|
var_dump(json_decode($json));
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
object(stdClass)#1 (1) {
|
|
["foo"]=>
|
|
string(3) "bar"
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
<example xml:id="stdclass.properties-example">
|
|
<title>Declaring dynamic properties</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$obj = new stdClass();
|
|
$obj->foo = 42;
|
|
$obj->{1} = 42;
|
|
var_dump($obj);
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
object(stdClass)#1 (2) {
|
|
["foo"]=>
|
|
int(42)
|
|
["1"]=>
|
|
int(42)
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</section>
|
|
|
|
</partintro>
|
|
|
|
</reference>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|