Professional Web Applications Themes

Syntax bug? - PHP Development

I use PHP 5.01. Could you see if it works in other vesions? If you declare an array: $a=array(1,2,3,4,5,); <------no error, even though there is a COMMA after "5"...

  1. #1

    Default Syntax bug?

    I use PHP 5.01. Could you see if it works in other vesions?

    If you declare an array:

    $a=array(1,2,3,4,5,); <------no error, even though there is a COMMA after
    "5"




    Hello Guest

  2. #2

    Default Re: Syntax bug?

    Hello wrote: 

    Yes it will, the last element will be NULL.


    JW



    Janwillem Guest

  3. #3

    Default Re: Syntax bug?

    On Sat, 28 May 2005 22:10:58 GMT, "Hello" <com> wrote:
     

    This works in all versions of PHP I've seen, and a similar thing works in Perl
    and array initialisation in C.

    Its main use is either for programmer laziness (you can just stick a comma on
    the end of each item, and you don't have to think about adding or removing
    commas if you re-order the values) or to simplify code-generation programs (so
    they don't have to worry about not putting a comma on the final item).

    It looks a bit funny as a one liner but less so when split across lines,

    $a = array(
    1,
    2,
    3,
    4,
    5,
    );

    The same doesn't apply to function parameters, though - a trailing comma
    produces a p error.

    --
    Andy Hassall / <co.uk> / <http://www.andyh.co.uk>
    <http://www.andyhsoftware.co.uk/space> Space: disk usage ysis tool
    Andy Guest

  4. #4

    Default Re: Syntax bug?

    On Sun, 29 May 2005 00:15:38 +0200, "Janwillem Borleffs" <com>
    wrote:
     
    >
    >Yes it will, the last element will be NULL.[/ref]

    It produces a five-element array, not six.

    --
    Andy Hassall / <co.uk> / <http://www.andyh.co.uk>
    <http://www.andyhsoftware.co.uk/space> Space: disk usage ysis tool
    Andy Guest

  5. #5

    Default Re: Syntax bug?

    Andy Hassall wrote: 

    Yeah, your right. I forgot to test with error_reporting set at a strict
    level.

    JW



    Janwillem Guest

Similar Threads

  1. Syntax Help
    By Scott in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: February 23rd, 04:31 AM
  2. $$ syntax
    By Koncept in forum PHP Development
    Replies: 4
    Last Post: April 10th, 07:45 PM
  3. Syntax again - Help!
    By Geoff in forum Macromedia Flash Sitedesign
    Replies: 4
    Last Post: November 18th, 11:23 PM
  4. Syntax
    By nonzero in forum UNIX Programming
    Replies: 4
    Last Post: September 13th, 08:17 PM
  5. Help with DB2 Syntax.
    By sharads in forum IBM DB2
    Replies: 1
    Last Post: July 3rd, 09:04 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139