note 103455 deleted from function.compact by danbrown

From: Date: Thu, 14 Apr 2011 14:58:43 +0000
Subject: note 103455 deleted from function.compact by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-178838@lists.php.net to get a copy of this message
Note Submitter: caron dot mike at gmail dot com ---- ryan, your error is a syntax error, not an undeclared array error. Functions that return arrays cannot be dereferenced inline. You must assign them to a variable before you can dereference it. To show that this is the case, here's a slightly modified version of your example: <?php $tom = "Thomas the Cat"; $jerry = "Jerry the Mouse"; $cat_and_mouse = compact('tom', 'jerry'); //these lines have the same output print_r($cat_and_mouse); print_r(compact('tom', 'jerry')); ?>

« previous php.notes (#178838) next »