Jump to content

Recommended Posts

this may be a bit of an oversimplification, but after searching the PHP manual for a solution and coming up NULL, i figured i'd share my thoughts:

i generally simply refer to it as a "pointer."

i know i have to be careful, especially working with C++ programmers since it's a different animal than pointers in C, but that's my take on it. since it's not really an operator, i don't know that it has a name
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-47350
Share on other sites

[quote author=wildteen88]
According to [url=http://uk.php.net/manual/en/tokens.php]this page[/url] (2/3 down the page) its called the Object operator.
[/quote]
very good eyes, wildteen

[quote author=wildteen88]
When I type the following:
$this->method();
I basically say call interal function method();
[/quote]
very similar here. i usually simply say something like "Object function method()." sometimes i'll go so far as to replace "Object" with the name of the Class it belongs to, if I'm working with multiple classes that have the same function names.
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-47382
Share on other sites

[quote author=emehrkay]
you know as you type along you do x equals y
$x = $y;

what do you say when you do this?
$this->

i usually say this into...

does the -> have an actual name?
[/quote]
actually,

$x = $y;

means assign the value of $y to $x.  it is not the same as saying $x equals $y. $x equal $y is what you'd say in a condition, like, if ($x == $y) { .. }  that is, if $x equals $y. 

= is assignment operator.
== is equality

as far as $this->blah .. if i have this:

$foo->bar = 'blah';

i usually say "assign 'blah' to bar of foo," or "assign 'blah' to foo's bar"

That's just how i 'say' it :\
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-47707
Share on other sites

  • 8 months later...
i normal say "owns" (in my head of course).

not cos i'm some sort of 10 year old gaming txt spkr, but because that's how i kinda got to understand it.

$this->that (this owns that, or that belongs to this)
$b->a (b owns a, or a belongs to b)
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-189873
Share on other sites

When I'm typing it, I generally call it "dot" because I started OOP with Java, and I just think to myself
class.method()
so I transfered that to php
$class->method() is still class dot method to me...
I guess I'm just weird. I've never had to say it out loud.
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-189929
Share on other sites

[quote author=jesirose link=topic=96282.msg534487#msg534487 date=1172014080]
When I'm typing it, I generally call it "dot" because I started OOP with Java, and I just think to myself
[/quote]

That's exactly what I do - I say "dot" in my mind, but my fingers make the translation from "." to "->" all on their own.
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-189930
Share on other sites

I never really read my code aloud, but I have sometimes wondered how I would explain some code if I had to since I do not know the names.
--
[quote author=redbullmarky link=topic=96282.msg534430#msg534430 date=1172008707]
i normal say "owns" (in my head of course).

not cos i'm some sort of 10 year old gaming txt spkr, but because that's how i kinda got to understand it.

$this->that (this owns that, or that belongs to this)
$b->a (b owns a, or a belongs to b)
[/quote]
0wn3d!!!1!!one1
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-189974
Share on other sites

I wonder why php used this syntax as they couldv'e easily used the "." operator as all other C type langs do. Java, C#, javascript and obviously c++.

Technically, "->" operator is used in c++ when accessing an object from a pointer. that is,
[code]
obj* obj1= &someobj;
*obj->method;
[/code]

I don't know the internals of php. But I think "->" is used just because "." is already "married??" with string concatation. Not because php uses pointers to access objs. 

Ok way offtopic. I call it dot. why bother using another word.
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-191223
Share on other sites

I can't say why the PHP developers chose the -> operator over the dot operator, but I disagree with jesi's comment.

It's not terribly difficult to have one operator that performs different operations depending on the context in which it's used.  PHP already does it with LPAREN, which denotes function arguments or order of operations.  C++ uses context to allow function overloading.  Javascript uses the + operator for both string concatenation and arithmetic addition.
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-192867
Share on other sites

[quote author=roopurt18 link=topic=96282.msg537457#msg537457 date=1172314033]
I can't say why the PHP developers chose the -> operator over the dot operator, but I disagree with jesi's comment.

It's not terribly difficult to have one operator that performs different operations depending on the context in which it's used.  PHP already does it with LPAREN, which denotes function arguments or order of operations.  C++ uses context to allow function overloading.  Javascript uses the + operator for both string concatenation and arithmetic addition.
[/quote]

But then we wouldn't be able to:

[code=php:0]$obj->{$foo.$bar}();
${$foo.$bar}->foobar;
$obj->${$foo.'bar'};[/code]

String concatenation and arithmetic addition are things that can't be combined in such a way.
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-192924
Share on other sites

I personally say "calls"... $dog->bark();

So in my head, I say "dog calls bark".  When I'm referencing a class variable "$dog->poop = yellow" I just simply say dog poop equals yellow... I personally think it differs depending on whether you're referencing a variable or a method/function.
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-192984
Share on other sites

[quote author=448191 link=topic=96282.msg537515#msg537515 date=1172326465]
But then we wouldn't be able to:

[code=php:0]$obj->{$foo.$bar}();
${$foo.$bar}->foobar;
$obj->${$foo.'bar'};[/code]
[/quote]

Not so.

[code]<?php
$obj->{$foo.$bar}();
// Would become...
$obj.{$foo.$bar}();
?>[/code]
If $foo is an object, we mean the property of $foo indicated by the variable $bar.  If $foo is not an object, we mean string concatenation, since there is no LPAREN after $bar.
If $obj is an object, we mean to call the method of $obj named after the concatenation of the variables $foo and $bar.  If $obj is not an object, we mean to concatenate the contents of $obj with the results of the function named after the concatenation of the variables $foo and $bar.

[code]<?php
${$foo.$bar}->foobar;
// Would become
${$foo.$bar}.foobar;
?>[/code]
If $foo is an object, we mean the property of $foo indicated by the contents of $bar.  If $foo is not an object, we mean string concatenation of $foo and $bar since $bar has no trailing LPAREN.
If the variable named for the result of the curly bracket expression is itself an object, we mean the foobar property of that object, otherwise you have a syntax error (expected T_DOLLAR_SIGN before 'foobar').

[code]<?php
$obj->${$foo.'bar'};
// Would become
$obj.${$foo.'bar'};
?>[/code]
If $foo is an object, it is converted to the string 'object' and concatenated with 'bar'.  This is done because 'bar' is not a legal identifier.  Otherwise the contents of $foo are concatenated with 'bar'.
If $obj is an object, we mean the property contained within the variable named by the curly bracket expression.  If $obj is not an object, we mean string concatenation.
Link to comment
https://forums.phpfreaks.com/topic/12379-how-do-you-say/#findComment-193079
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.