note 126627 added to class.stringable
| From: | Gormack at main dot php dot net | Date: | Sun, 21 Nov 2021 02:49:04 +0000 |
| Subject: | note 126627 added to class.stringable | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217273@lists.php.net to get a copy of this message | ||
Since it's introduced in PHP 8, IPv4Address class Example #1 could be shortened to:
<?php
class IPv4Address implements Stringable {
public function __construct(private string $oct1, private string $oct2, private string $oct3,
private string $oct4) {
}
public function __toString(): string {
return "$this->oct1.$this->oct2.$this->oct3.$this->oct4";
}
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 109.125.252.103)
----
Manual Page -- https://php.net/manual/en/class.stringable.php
Edit -- https://main.php.net/note/edit/126627
Del: integrated -- https://main.php.net/note/delete/126627/integrated
Del: useless -- https://main.php.net/note/delete/126627/useless
Del: bad code -- https://main.php.net/note/delete/126627/bad+code
Del: spam -- https://main.php.net/note/delete/126627/spam
Del: non-english -- https://main.php.net/note/delete/126627/non-english
Del: in docs -- https://main.php.net/note/delete/126627/in+docs
Del: other reasons-- https://main.php.net/note/delete/126627
Reject -- https://main.php.net/note/reject/126627
Search -- https://main.php.net/manage/user-notes.php