Jump to content

Illegal Offset


JeffT

Recommended Posts

Hey all, very new to PHP, but I want to pass a class into an array, but I seem to be doing something illegal :P

 

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.