> i'm really lazy about typing.
I think every good programmer is... ;-)
--
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)
--
PHP General Mailing List (
On 5/2/09 6:45 AM, "Robert Cummings" wrote:
> It's not what I want, I'm not the original poster.
as op, i think i'm going to stick with the cast. but it's been an
interesting thread and i learned some useful things.
> Regardless though, it
> comes down to the preference of the developer. It ca
On Sat, 2009-05-02 at 12:10 +0100, Ashley Sheridan wrote:
> On Sat, 2009-05-02 at 06:45 -0400, Robert Cummings wrote:
> > On Sat, 2009-05-02 at 12:39 +0200, Andrea Giammarchi wrote:
> > > exactly, why bother with JavaScript literal representation?
> > >
> > > the foreach loop was just an alternat
On Sat, 2009-05-02 at 06:45 -0400, Robert Cummings wrote:
> On Sat, 2009-05-02 at 12:39 +0200, Andrea Giammarchi wrote:
> > exactly, why bother with JavaScript literal representation?
> >
> > the foreach loop was just an alternative to explicit object cast cause you
> > did not like it I th
On Sat, 2009-05-02 at 12:39 +0200, Andrea Giammarchi wrote:
> exactly, why bother with JavaScript literal representation?
>
> the foreach loop was just an alternative to explicit object cast cause you
> did not like it I though it was more about control over what you want to
> cast and what
php
you have natural type hint over arrays and these are normally slightly faster
so I do not get why you want objects rather than arrays ...
> Subject: RE: [PHP] object literals
> From: rob...@interjinn.com
> To: an_...@hotmail.com
> CC: f...@thefsb.org; php-general@lists.php.net
&g
On Fri, 2009-05-01 at 17:52 +0200, Andrea Giammarchi wrote:
> you are in PHP, not in JavaScript.
>
> In PHP arrays are like collections or hash tables.
> if you strictly need object cause
>
> $o->stuff
> is better than
> $o['stuff']
>
> having exactly the same number of characters, you can creat
ooops sorry, two more ;-)
> having exactly the same number of characterss.aspx
_
Windows Live™: Keep your life in sync. Check it out!
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009
ray {
// no way
}
Regards
> From: rob...@interjinn.com
> To: an_...@hotmail.com
> CC: f...@thefsb.org; php-general@lists.php.net
> Date: Fri, 1 May 2009 11:40:11 -0400
> Subject: RE: [PHP] object literals
>
> On Fri, 2009-05-01 at 17:36 +0200, Andrea Giammarchi wrote:
>
On Fri, 2009-05-01 at 17:36 +0200, Andrea Giammarchi wrote:
> var o = {
> "a" : "b",
> "c" : "d"
> };
>
> $o = array(
> 'a' => "b",
> 'c' => "d"
> );
>
> so I guess the problem is a couple of quotes, isn't it?
>
>
> otherwise define object statically and externally and use json_
se json_decode ;-)
> Date: Thu, 30 Apr 2009 16:56:21 -0400
> From: f...@thefsb.org
> To: php-general@lists.php.net
> Subject: [PHP] object literals
>
> is there a neat literal syntax for creating objects on the fly without
> defining a type?
>
> whenever i need to do
On 5/1/09 4:54 AM, "Richard Heyes" wrote:
> Hi,
>
>> $x = (object) array('a'=>1, 'b'=>3, ...);
>>
>> which works but isn't very lovely. it's neater in, for example, javascript.
>
> Well, you could wrap it up in a function to make it a bit lovelier. Eg:
>
> $foo = createObject(array('key' =
Hi,
> You could use JSON,
>
> $foo = json_decode('{"a":1,"b":3}');
>
> but I guess that's not much better than Richard's suggestion.
Didn't think of that (well... it's new). That's actually much better I
think, since you get the added boon of ease of portability to JS (if
that's even a factor).
Richard Heyes wrote:
> Hi,
>
>>$x = (object) array('a'=>1, 'b'=>3, ...);
>>
>> which works but isn't very lovely. it's neater in, for example, javascript.
>
> Well, you could wrap it up in a function to make it a bit lovelier. Eg:
>
> $foo = createObject(array('key' => 'value'));
>
> It's n
Hi,
> $x = (object) array('a'=>1, 'b'=>3, ...);
>
> which works but isn't very lovely. it's neater in, for example, javascript.
Well, you could wrap it up in a function to make it a bit lovelier. Eg:
$foo = createObject(array('key' => 'value'));
It's not great, but PHP doesn't have a object
is there a neat literal syntax for creating objects on the fly without
defining a type?
whenever i need to do it i do something like
$x = (object) array('a'=>1, 'b'=>3, ...);
which works but isn't very lovely. it's neater in, for example, javascript.
--
PHP General Mailing List (http://w
16 matches
Mail list logo