php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #40583 No explanation of "Illegal offset type"
Submitted: 2007-02-21 19:05 UTC Modified: 2012-05-21 19:23 UTC
From: darrenoh at sidepotsinternational dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: OS X
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: darrenoh at sidepotsinternational dot com
New email:
PHP Version: OS:

 

 [2007-02-21 19:05 UTC] darrenoh at sidepotsinternational dot com
Description:
------------
I'm having a problem with unset generating an "Illegal offset 
type" error when I unset an array. My complaint is that 
there's no way to find out what the error means or why the 
unset command would generate it.

Reproduce code:
---------------
      foreach ($form['taxonomy'] as $vid) {
        if (substr($vid, 0, 1) != '#') {
          unset($form['taxonomy'][$vid]);
        }
      }


Expected result:
----------------
I expected to be given an error message that I could find an 
explanation for somewhere.

Actual result:
--------------
I found no explanation anywhere.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-22 14:21 UTC] dmytton@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

You cannot use arrays or objects as keys. Doing so will result in a warning: Illegal offset type. Check your code.
 [2007-02-22 15:51 UTC] cynic@php.net
the OP is complaining that it's not documented, not that it's happening.
 [2007-02-22 15:56 UTC] dmytton@php.net
Yes, but it's documented in http://www.php.net/types.array which covers the use of an array as a key anywhere in any PHP code. It's not really specific to the unset() function.
 [2007-02-22 16:03 UTC] darrenoh at sidepotsinternational dot com
There needs to be a way to search documentation for error 
messages like this. Maybe a PHP wiki?
 [2007-02-22 16:07 UTC] dmytton@php.net
If you enter illegal offset type into the search box top right and select "online documentation" from the drop menu.

The first result in the search is:

Arrays - Manual
A map is a type that maps values to keys. This type is optimized in several ways, so you can ... Doing so will result in a warning: Illegal offset type. ...
php.net/manual/en/language.types.array.php - 21 Feb 2007

Even if you search google for the same query, the relevant PHP page is first ;)
 [2012-05-21 19:14 UTC] aholovsky at gmail dot com
Your code should be:

Reproduce code:
---------------
      foreach ($form['taxonomy'] as $key -> $vid) {
        if (substr($vid, 0, 1) != '#') {
          unset($form['taxonomy'][$key]);
        }
      }
 [2012-05-21 19:23 UTC] darrenoh at sidepotsinternational dot com
Thank you. I would still like to see a section of the documentation devoted to 
error messages.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 26 20:01:33 2024 UTC