Jump to content

jcampbell1

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jcampbell1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Glyde, Thanks for your responses. Do you know if php6 will support this? thx, john
  2. I am not really trying to accomplish anything except understand the language a little better. I am just surprised that the -> operator can be applied to the result of a function, but the [] operator cannot be. But here is a case where you have to use list, which I think is a syntacticly gross: I would like $value = mysql_fetch_row(mysql_qyery('SELECT MAX(id) FROM table'))[0]; instead of: list($value) = mysql_fetch_row(mysql_query('SELECT MAX(id) FROM table')); I also think it is better to avoid having intermediate values hanging around, because you can't garbage collect with a bunch of intermediate variables lying around in scope.
  3. I just don't understand why a function that returns an array doesn't act like an array. It works fine in python/javascript... see: <script type="text/javascript"> function get_dog() { a = new Array(); a[0] = 'hello'; a[1] = 'world'; return a; } function alert_message() { alert(get_dog()[0] + get_dog()[1]); } alert_message(); </script>
  4. that uses an intermediate assignment... consider this.... <?php echo get_dog()['legs']; //fails echo get_dog2()->legs; // works function get_dog() { return array('legs'=>4,'tails'=>1,'ears'=>2); } class dog {} function get_dog2() { $dog = new dog; $dog->legs = 4; $dog->tails = 1; $dog->ears =2; return $dog; } ?>
  5. why doesn't this work? is there a workaround with out doing an intermediate assignment? <?php echo get_dog()['legs']; function get_dog() { return array('legs'=>4,'tails'=>1,'ears'=>2); } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.