Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99788 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33249 invoked from network); 6 Jul 2017 07:04:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jul 2017 07:04:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=php-lists@koalephant.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php-lists@koalephant.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain koalephant.com designates 206.123.115.54 as permitted sender) X-PHP-List-Original-Sender: php-lists@koalephant.com X-Host-Fingerprint: 206.123.115.54 mail1.25mail.st Received: from [206.123.115.54] ([206.123.115.54:35686] helo=mail1.25mail.st) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F6/77-15131-F01ED595 for ; Thu, 06 Jul 2017 03:04:47 -0400 Received: from [192.168.1.25] (unknown [49.48.242.73]) by mail1.25mail.st (Postfix) with ESMTPSA id 66C0F60481; Thu, 6 Jul 2017 07:04:39 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) In-Reply-To: Date: Thu, 6 Jul 2017 14:04:34 +0700 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: To: "Khawer ." X-Mailer: Apple Mail (2.3124) Subject: Re: [PHP-DEV] Change -> to dot(.) From: php-lists@koalephant.com (Stephen Reay) > On 6 Jul 2017, at 13:13, Khawer . wrote: >=20 > In all major programming languages we access object properties and = methods > using dot(.). >=20 > C#: > Abc Abc =3D new Abc(); > Abc.method(); >=20 > Java: > Abc Abc =3D new Abc(); > Abc.method(); >=20 > JavaScript: > var apple =3D new function() { > this.name =3D "Test"; > } > alert(apple.name()); >=20 >=20 > Why not to make PHP similar to these languages by allowing to access = object > properties and methods using dot(.). We will still keep "->" until PHP = 8 to > maintain backward compatibility. In each of those languages, the plus operator is used for string = concatenation. In PHP the dot operator is used for string concatenation, and objects = can be cast to strings when concatenating, so how do you differentiate = the two calls at the end of this block: class Bar { public function baz() {=E2=80=A6} public function __toString(): string {...} } function baz(): string {=E2=80=A6} $foo =3D new Bar(); $foo.baz(); // call method Baz on object $foo $foo.baz(); // concat the result of casting $foo to string, with the = result of calling baz()=