1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-24 07:42:22 +01:00
Files
archived-doc-ru/language/predefined/stdclass.xml
Mikhail Alferov 505546f0ee Update 77325b6 to En (#1140)
* Update php-incomplete-class.xml to en

* Update stdclass.xml to en

* Update stdclass.xml to en

* Update allowdynamicproperties.xml to en

* Update attribute.xml to en

* Update deprecated.xml to en

* Update override.xml to en

* Update returntypewillchange.xml to en

* Update sensitiveparameter.xml to en

* Update deprecated.xml fix CS

* Update override.xml fix CS

* Update stdclass.xml Fix XML syntax error
2026-01-21 05:29:36 +03:00

146 lines
4.1 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 77325b622f91355b118e8f3bc9ff940e8201f55d Maintainer: sergey Status: ready -->
<!-- Reviewed: no -->
<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>Класс stdClass</title>
<titleabbrev>stdClass</titleabbrev>
<partintro>
<section xml:id="stdclass.intro">
&reftitle.intro;
<para>
Пустой класс общего назначения с динамическими свойствами.
</para>
<para>
Объекты стандартного класса создают оператором
<link linkend="language.oop5.basic.new">new</link>
или путём <link linkend="language.types.object.casting">приведения к объекту</link> значения другого типа.
Ряд PHP-функций тоже создаёт экземпляры этого класса,
например, <function>json_decode</function>, <function>mysqli_fetch_object</function>
или <methodname>PDOStatement::fetchObject</methodname>.
</para>
<para>
Класс поддерживает динамические свойства
и не требует атрибута <code>#[\AllowDynamicProperties]</code>,
хотя не реализует магических методов
<link linkend="object.get">__get()</link> и <link linkend="object.set">__set()</link>.
</para>
<para>
Это не базовый класс, поскольку PHP не включает понятия универсального базового класса.
При этом возможно создать пользовательский класс, который расширит класс <classname>stdClass</classname>
и поэтому унаследует поддержку динамических свойств.
</para>
</section>
<section xml:id="stdclass.synopsis">
&reftitle.classsynopsis;
<classsynopsis class="class">
<ooclass>
<modifier role="attribute">#[\AllowDynamicProperties]</modifier>
<classname>stdClass</classname>
</ooclass>
</classsynopsis>
<para>
Класс не содержит методов или свойств по умолчанию.
</para>
</section>
<section xml:id="stdclass.examples" role="examples">
&reftitle.examples;
<example xml:id="stdclass.basic-example">
<title>Приведение к объекту значения другого типа</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>Возврат объекта функцией <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>Объявление динамических свойств</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
-->