View Single Post
Old 04-23-2009, 09:39 AM   #17 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by allworknoplay View Post
I'll look into the object literal, that doesn't look like it's something that is available in PHP right?
Sounds pretty cool though, almost like a shortcut to using objects...
No, as Kalle said, object literals are not in PHP (yet). The closest thing, visually, that I can think of would be:

PHP Code:
$retval = (object) array(
  
'checkbox' => 0,
  
'radio'    => 0,
  
'total'    => 0
);

++
$retval->total;
print_r($retval); 
The ArrayObject (in PHP) would also allow the object- and array-syntaxes to be used ($retval->total and $retval['total']) if you wanted/needed them both.

Quote:
Originally Posted by allworknoplay View Post
On your last explanation:

++retval[…]


Would that be considered a unary operator?
Yep, because the operator acts on only one variable, it is a unary operation.

Quote:
Originally Posted by allworknoplay View Post
You have a PHP.net account! You can make it happen!!
PHP is an open source project, meaning anyone is free to contribute. A php.net account is not required!
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
allworknoplay (04-23-2009)