> -----Original Message----- > From: Tom Robinson [mailto:tom.robinson@xxxxxxxxxxxx] > Sent: Tuesday, December 07, 2010 4:03 PM > To: php-general@xxxxxxxxxxxxx > Subject: PHP4 to PHP5 migration with E_STRICT > > Hi, > > I'm migrating a web application written for PHP4 to PHP5. I've turned on > E_STRICT to have a detailed look at all the code thoroughly. I have a number > of 'Notices' and 'Strict Standards' messages appearing now. > > I don't consider myself a PHP guru by any means so I'm seeking help with > understanding these messages and how to fix the code. > > One of the messages is: > > "PHP Strict Standards: Only variables should be assigned by reference in" > > This is for a class SPControlPanel with a method > > function getContentTypes(&$db) > { > $tabledata = array(); > > $sql = "select > contenttype.* > from > contenttype"; > > return $db->queryAll($sql, true); > } > > The warning is for this segment of code below which is another method in > the same class (marked with comment // this line): > > function getCategoryTypes(&$db) { > $tabledata = array(); > > $myContentTypes = &SPControlPanel::getContentTypes($db); // this > line > foreach ($myContentTypes as $key => $data) { > if ($data['iscategory']) $tabledata[] = $data['contenttype']; > } > > return $tabledata; > } > > There are many more methods making assignments in a similar way in this > class and in other classes throughout the code. > > I'm not sure of the best way to re-code this to resolve the E_STRICT warning. > > Any help is much appreciated. > > Regards, > > Tom > IIRC, objects are passed by referenced in PHP5. There's no need to '&' by the object variable. Remove the & and do a var_dump and you'll see it refers the same class object #. Regards, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php