curly braces or square brackets?

curly braces or square brackets?

am 17.10.2007 00:31:50 von grande news

Hi, I've got some PHP code that looks like this

$cura= ord($data{$pnum*2});
$curb = ord($data{$pnum*2+1});

Notice the curly braces -- does using them make any difference, or will
square brackets do the same thing?

Thanks
B

Re: curly braces or square brackets?

am 17.10.2007 00:56:20 von luiheidsgoeroe

On Wed, 17 Oct 2007 00:31:50 +0200, Grande News wrote:

> Hi, I've got some PHP code that looks like this
>
> $cura=3D ord($data{$pnum*2});
> $curb =3D ord($data{$pnum*2+1});
>
> Notice the curly braces -- does using them make any difference, or wil=
l
> square brackets do the same thing?

It will do the same thing. However:
http://www.php.net/~derick/meeting-notes.html#cleanup-for-vs

Although it still doesn't throw an E_STRICT in 5.2, I'd use square =

brackets instead of curly braces.
-- =

Rik Wasmus

Re: curly braces or square brackets?

am 17.10.2007 02:43:11 von Macca

Use square brackets. Curly braces were a fad. something to do with the
parser interpretation or something. I heard that they will be
depreceted as of php6 though.

Re: curly braces or square brackets?

am 17.10.2007 11:44:53 von henri

On Tue, 16 Oct 2007 17:31:50 -0500, Grande News wrote:

> Hi, I've got some PHP code that looks like this
>
> $cura= ord($data{$pnum*2});
> $curb = ord($data{$pnum*2+1});
>
> Notice the curly braces -- does using them make any difference, or will
> square brackets do the same thing?
>
> Thanks
> B

curly braces are perl syntax.