note 103455 added to function.compact

From: Date: Thu, 14 Apr 2011 11:38:24 +0000
Subject: note 103455 added to function.compact
Groups: php.notes 
Request: Send a blank email to php-notes+get-178822@lists.php.net to get a copy of this message
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')); ?> ---- Server IP: 72.55.140.6 Probable Submitter: 173.32.114.104 ---- Manual Page -- http://www.php.net/manual/en/function.compact.php Edit -- https://master.php.net/note/edit/103455 Del: integrated -- https://master.php.net/note/delete/103455/integrated Del: useless -- https://master.php.net/note/delete/103455/useless Del: bad code -- https://master.php.net/note/delete/103455/bad+code Del: spam -- https://master.php.net/note/delete/103455/spam Del: non-english -- https://master.php.net/note/delete/103455/non-english Del: in docs -- https://master.php.net/note/delete/103455/in+docs Del: other reasons-- https://master.php.net/note/delete/103455 Reject -- https://master.php.net/note/reject/103455 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178822) next »