.

Being careful with list($x,$y) = func($z); |

When you are writing PHP and you expect an array back from a function you can do this

list($name,$age) = function($person);

There is one small problem with doing this. If the array that comes back is not the proper size you are going to get an error.

As I see it you have two options :

  • Make sure that the function defaults to returning an array of an approriate size. This is possible easier said than done
  • Get the array back do nomal tests on it before you start assigning it

So basically, the list() function is handy - but you have to be very careful when you use it or it will blow up.

One Response to 'Being careful with list($x,$y) = func($z);'

Leave a Reply

Moderation Active: Old stuff here... Therefore your comment on this post will be moderated (i.e. don't submit twice !)

    Categories
    Archives

    .