Connecting Tech Pros Worldwide Forums | Help | Site Map

Bits an pieces

Geoff Berrow
Guest
 
Posts: n/a
#1: Jul 17 '05
I'm having some difficulty in finding references and definitions of
language constructs. By their nature they are hard to search for. For
instance I use

foreach($array as $key=>$value){ etc..}

But what is ' =>' called?

I've got similar confusion with the &

I know I've got to do some study (eventually) of OO techniques but they
also use symbols which are hard to find. e.g. '->', '::'


--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Senator Jay Billington Bulworth
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Bits an pieces


Geoff Berrow <blthecat@ckdog.co.uk> wrote in
news:l9oo019qhit4p8an4ec5inv0ehu4pjtv4p@4ax.com:
[color=blue]
> I'm having some difficulty in finding references and definitions of
> language constructs. By their nature they are hard to search for. For
> instance I use
>
> foreach($array as $key=>$value){ etc..}
>
> But what is ' =>' called?[/color]

I'm not sure if PHP even has a name for it. In C, the equivalents (i.e.
-> and .) are often referred to as the "member" operator, because they're
pointing to a member of a class or structure.
[color=blue]
> I've got similar confusion with the &[/color]

This is the called the "bitwise and" operator. You're far more likely to
run into &&, which is simply another way of writing "and" - the "logical
and" operator. It's a fair bet that if you needed to use the bitwise &,
you'd already know what it does.
[color=blue]
> I know I've got to do some study (eventually) of OO techniques but they
> also use symbols which are hard to find. e.g. '->', '::'[/color]

When you have a couple of spare hours, go over the basics in the PHP
manual, <http://php.net/manual>. The manual is laid out such that even if
you don't know the name of what you're looking for, you can probably find
it by scanning the Table of Contents or one of the main sections. For
example, if you know you're going to be dealing with an array e.g.
[color=blue]
>foreach($array as $key=>$value){ etc..}[/color]

....you could find the "Language Reference > Types > Arrays" and "Array
Functions" sections fairly quickly. Even if (as in my case and yours) you
don't know for sure what the => is called.

hth


--

Bulworth : PHP/MySQL/Unix | Email : str_rot13('f@fung.arg');
--------------------------|---------------------------------
<http://www.phplabs.com/> | PHP scripts, webmaster resources
Alvaro G Vicario
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Bits an pieces


*** Geoff Berrow wrote/escribió (Fri, 11 Feb 2005 07:48:34 +0000):[color=blue]
> I'm having some difficulty in finding references and definitions of
> language constructs.[/color]

http://www.php.net/manual/en/langref.php


--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Andy Hassall
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Bits an pieces


On Fri, 11 Feb 2005 07:48:34 +0000, Geoff Berrow <blthecat@ckdog.co.uk> wrote:
[color=blue]
>I'm having some difficulty in finding references and definitions of
>language constructs. By their nature they are hard to search for. For
>instance I use
>
>foreach($array as $key=>$value){ etc..}
>
>But what is ' =>' called?[/color]

Well, PHP has some Perl roots, where => is called a "fat comma" due to it
being just syntactic sugar in hashes. The name probably makes even less sense
in PHP.

I always read loops as above as "foreach array as key 'to' value". In the gory
depths of the Zend PHP language parser, it's referred to as "T_DOUBLE_ARROW".
[color=blue]
>I've got similar confusion with the &[/color]

Reference operator; similar to C++, although it's postfix there - when a
prefix in C++ and C it's the "address of" operator.
[color=blue]
>I know I've got to do some study (eventually) of OO techniques but they
>also use symbols which are hard to find. e.g. '->', '::'[/color]

-> would be something like "member operator" or "dereferencing operator". The
parser calls it "T_OBJECT_OPERATOR".

:: is the "scope resolution operator".

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Geoff Berrow
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Bits an pieces


I noticed that Message-ID: <hebq01pbba2p2shmt60e66e5mafdoagkjt@4ax.com>
from Andy Hassall contained the following:
[color=blue][color=green]
>>foreach($array as $key=>$value){ etc..}
>>
>>But what is ' =>' called?[/color]
>
> Well, PHP has some Perl roots, where => is called a "fat comma" due to it
>being just syntactic sugar in hashes. The name probably makes even less sense
>in PHP.[/color]

Hmmm, you're right.[color=blue]
>
> I always read loops as above as "foreach array as key 'to' value". In the gory
>depths of the Zend PHP language parser, it's referred to as "T_DOUBLE_ARROW".[/color]

I kind of like the idea that we all use something regularly that doesn't
appear to have a name. :-)

I propose we call it the 'andits' operator.

$key andits $value. geddit?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jan Pieter Kunst
Guest
 
Posts: n/a
#6: Jul 17 '05

re: Bits an pieces


Andy Hassall wrote:
[color=blue]
> :: is the "scope resolution operator".[/color]

In the gory depths of the Zend PHP language parser, also known as
T_PAAMAYIM_NEKUDOTAYIM.

Do something like this:

$class::method();

and watch the error message.

JP

--
Sorry, <devnull@cauce.org> is a spam trap.
Real e-mail address unavailable. 5000+ spams per month.
Closed Thread