Re: Object literals in php?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Oct 9, 2015, at 12:47 AM, Mogens Melander wrote:

Nothing wrong with that construction :)

<?php

       function blah($a)
       {
               echo $a[0];
       }

       blah(array('BlaBla'));

?>

# php -f test.php

BlaBla

Thank you:
I have been doing similar things* in javascript frequently
and it will be useful in php as well.

*using anonymous object literals (because javascript does
not have associative arrays)

In this sense I would do
array('something'=>"blahblah")

as in:
function blah($a)
              {
               echo $a['something'];
             }
blah(array('something'=>"blahblah"))
JK


On 2015-10-07 06:10, Jeffry Killen wrote:
On Oct 6, 2015, at 2:29 PM, Aziz Saleh wrote:
On Tue, Oct 6, 2015 at 5:24 PM, Jeffry Killen <jekillen@xxxxxxxxxxx> wrote:
Hello:
Is it possible to use anonymous arrays?
function blah( a )
             {
               // doittoit
             }
blah(array('var')) // I have to review array creation syntax
Thanks for attention
JK
-- PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
I mean no disrespect, but did you even try running the code?
No; no offense taken;
I would need to get refreshed on array creation syntax
in this situation before trying it.
I realized that the function def has parameter 'a' which I should
have written $a ( I switch a lot between php and javascript development)
JK
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
Mogens
+66 8701 33224


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux