JeffT Posted March 9, 2007 Share Posted March 9, 2007 Hey all, very new to PHP, but I want to pass a class into an array, but I seem to be doing something illegal here is the details $characterListing = array($me=>$me->GetIsPlayer(), $him=>$him->GetIsPlayer()); error message: Warning: Illegal offset type in c:\Inetpub\wwwroot\MyProjects\SecondOffering\htmlFns.php on line 133 How can I get around this? Link to comment https://forums.phpfreaks.com/topic/41905-illegal-offset/ Share on other sites More sharing options...
benjaminbeazy Posted March 9, 2007 Share Posted March 9, 2007 You cannot use arrays or objects as keys. Doing so will result in a warning: Illegal offset type Link to comment https://forums.phpfreaks.com/topic/41905-illegal-offset/#findComment-203189 Share on other sites More sharing options...
JeffT Posted March 9, 2007 Author Share Posted March 9, 2007 Does anyone know how I can make a listing of classes so I can process them all at once? Link to comment https://forums.phpfreaks.com/topic/41905-illegal-offset/#findComment-203195 Share on other sites More sharing options...
benjaminbeazy Posted March 9, 2007 Share Posted March 9, 2007 you can try this.. $first = $me->GetIsPlayer(); $second = $him->GetIsPlayer(); $characterListing = array(me => $first, him => $second); Link to comment https://forums.phpfreaks.com/topic/41905-illegal-offset/#findComment-203201 Share on other sites More sharing options...
Glyde Posted March 9, 2007 Share Posted March 9, 2007 Try this instead: $first = $me->GetIsPlayer(); $second = $him->GetIsPlayer(); $characterListing = array('me' => $first, 'him' => $second); You need to remember that not everyone has error_reporting to E_ALL ^ E_NOTICE, and setting me => $first (without the quotes, indicating it is a string) can cause an undefined error. Link to comment https://forums.phpfreaks.com/topic/41905-illegal-offset/#findComment-203206 Share on other sites More sharing options...
benjaminbeazy Posted March 9, 2007 Share Posted March 9, 2007 yeah that's true Link to comment https://forums.phpfreaks.com/topic/41905-illegal-offset/#findComment-203207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.