note 128401 added to language.oop5.visibility
| From: | alperenberatdurmus at gmail dot com | Date: | Mon, 17 Apr 2023 08:57:13 +0000 |
| Subject: | note 128401 added to language.oop5.visibility | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220356@lists.php.net to get a copy of this message | ||
Dynamic properties are "public".
<?php
class MyClass {
public function setProperty($value) {
$this->dynamicProperty = $value;
}
}
$obj = new MyClass();
$obj->setProperty('Hello World');
echo $obj->dynamicProperty; // Outputs "Hello World"
?>
This usage is the same as well:
<?php
class MyClass {
}
$obj = new MyClass();
$obj->dynamicProperty = 'Hello World';
echo $obj->dynamicProperty; // Outputs "Hello World"
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 95.70.151.206)
----
Manual Page -- https://php.net/manual/en/language.oop5.visibility.php
Edit -- https://main.php.net/note/edit/128401
Del: integrated -- https://main.php.net/note/delete/128401/integrated
Del: useless -- https://main.php.net/note/delete/128401/useless
Del: bad code -- https://main.php.net/note/delete/128401/bad+code
Del: spam -- https://main.php.net/note/delete/128401/spam
Del: non-english -- https://main.php.net/note/delete/128401/non-english
Del: in docs -- https://main.php.net/note/delete/128401/in+docs
Del: other reasons-- https://main.php.net/note/delete/128401
Reject -- https://main.php.net/note/reject/128401
Search -- https://main.php.net/manage/user-notes.php