Bits an pieces

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Berrow

    #1

    Bits an pieces

    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

    #2
    Re: Bits an pieces

    Geoff Berrow <blthecat@ckdog .co.uk> wrote in
    news:l9oo019qhi t4p8an4ec5inv0e hu4pjtv4p@4ax.c om:
    [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($arr ay 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@fu ng.arg');
    --------------------------|---------------------------------
    <http://www.phplabs.com/> | PHP scripts, webmaster resources

    Comment

    • Alvaro G Vicario

      #3
      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]




      --
      -- Álvaro G. Vicario - Burgos, Spain
      -- Thank you for not e-mailing me your questions
      --

      Comment

      • Andy Hassall

        #4
        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($arr ay 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 "dereferenc ing operator". The
        parser calls it "T_OBJECT_OPERA TOR".

        :: is the "scope resolution operator".

        --
        Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
        <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

        Comment

        • Geoff Berrow

          #5
          Re: Bits an pieces

          I noticed that Message-ID: <hebq01pbba2p2s hmt60e66e5mafdo agkjt@4ax.com>
          from Andy Hassall contained the following:
          [color=blue][color=green]
          >>foreach($arra y 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/

          Comment

          • Jan Pieter Kunst

            #6
            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_NEKU DOTAYIM.

            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.

            Comment

            Working...