4
AllenII
8y

!rant

PHP guys, your equivalent to the dot operator looks weird to me with no whitespace, anybody else spaces out their arrows like this?

Comments
  • 4
    No, didn't even knew it's valid.
    Aesthetically speaking, I don't like much, 😊
  • 1
    I always do

    app->getContainer()

    Thinking bout
    app.getContainer()

    Do you do

    app . getContainer() ?

    I didn't know you could add space around it. Curious about other php devs. Looks weird to me apart tho haha
  • 1
    looked to me like an anonymous function
  • 0
    Yeah its weird, i didn't notice it was php.
  • 1
    Funny that you guys didn't know it was valid--it's not my first time spacing them. Well if it looks that weird to you all, ill do the sensible thing and stick to convention. Thanks everyone
  • 1
    Also, don't do ?> at the end. It prevents you from leaking unintended whitespace in your output.
  • 3
    That's just a waste of space...
  • 1
    @hjk101 i do agree; I dont know why, the arrows look weird to me period. I guess I'll get used to it soon enough because im starting up a project using Slim to make the API
  • 1
    @AllenII
    You do get used to it but almost every other language uses a dot. As I'm multilingual I sometimes pick the wrong operator.
    In Perl the dereferencing is even inconsistent: $hash{key}; vs $hashref->{key};. In php it's just a different operator (a one character to long operator at that).
  • 0
  • 1
    I like it better without the spaces. But occasionally I do this:
    $app->getContainer()
    ->getSubject()
    ->getSystem()
    ->getPath();
  • 0
    Hell no, that looks weird
  • 0
    In C, dereferencing + access to method uses the -> operator as well, so I can just imagine everything's a pointer and it makes sense
Add Comment