Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Mick79's avatar

Why does Laravel use -> instead of just a dot?

It just occurred to me this evening that it's annoying having to use two keystrokes each time when a "dot" would be perfectly sufficient. I use C# in My day job and the dot notation there seems more natural.

0 likes
2 replies
pom's avatar
pom
Best Answer
Level 21

The object operator -> is a PHP thing which is what Laravel is written in. The arrow operator -> exists in C/C++ too, it's used to access the members of the structure or the unions using pointers.

jlrdw's avatar

Also linq has

var entity = db.Invoice.Where(x => x.InvoiceID == vinvoiceid).First();

Not arrow but still not all dots.

Please or to participate in this conversation.