|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-04-29 18:34 UTC] igordonin at gmail dot com
Description:
------------
Development Environment is PHP 5.2.5, Apache 2.2.
When requesting PHP to unset an array item, there's a fatal error:
Fatal error: Cannot unset string offsets in C:\[hidden]\index.php on line 147
When I var_dump the array variable, the array item is not show as part of that array, but the unset array item command is inside a if (isset($variable["ArrayName"])) { ... which means that the item has to exist in order for the unset to occur.
-----
On my production enviroment, though, I'm running PHP Version 4.3.9, with Apache Handler 2.0.52(Oracle) | API Version 20020903, and it does not cause a Fatal Error, but the error is still there. Here's the URL:
http://helpdesk.mozart.com.br/public/index.php
-> Try to connect with anything. It matters not, I think.
If this is not a bug, I do apologize. It's just that I've checked this code so many times and I can't find anything wrong ...
Thanks in advance.
Reproduce code:
---------------
# 1. Execute Query
$Query["Try_Login"] = Query_Repository("Try_Login", 0, 2, 0);
echo "<br><br> This is the var_dump for array \$Query: <br>";
var_dump($Query);
echo "<br><br>";
if (isset( $Query["Try_Login"]["Error"] )) { echo "<br><br>\$Query[\"Try_Login\"][\"Error\"] is set as: \"" . $Query["Try_Login"]["Error"] . "\".<br><br>"; }
die();
Here are the URLs for the functions that you might need to take a look at. I saved them as txt so you may check them out.
Query_Repository:
http://helpdesk.mozart.com.br/public/query_repository.txt
Request_Value:
http://helpdesk.mozart.com.br/public/request_value.txt
validate_input:
http://helpdesk.mozart.com.br/public/validate_input.txt
Expected result:
----------------
$Query["Try_Login"] was supposed to be set only as string, either with "conn_err" or "conn_ok". That's all var_dump really shows, and that's what it's supposed to be ...
Actual result:
--------------
... but it was also supposed to not have an ["Error"] array Item. It's not shown while using var_dump, but "isset" returns true, and it's value is set to string "c". Still, I cannot unset it for it may produce a fatal error.
Fatal error: Cannot unset string offsets in C:\[hidden]\index.php on line 147
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 31 22:00:01 2025 UTC |
You're wrong, var_dump says: array(1) { ["Try_Login"]=> string(8) "conn_err" } It's so an array!You're right! But is this expected to return true? if (isset($Query["Try_Login"]["Error")) { unset($Query["Try_Login"]["Error"]); } 'Cause that's when I'm trying to unset $Query["Try_Login"]["Error"] ...Hey, I don't mean to be annoying, hope didn't get there yet, but check this out: Query_Repository returns string "conn_err", so it's the same as: $Query["Try_Login"] = "conn_err"; var_dump( $Query ) results in: array(1) { ["Try_Login"]=> string(8) "conn_err" } There's no suck key as ["Error"] at all ... So what you mean is that isset will recognize $Query["Try_Login"]["Error"] as $Query["Try_Login"][0] because of the string offset and then return true? You may be right, that may be in fact the current behavior, but I don't see how that can be the best behavior at all! I'm no expert though. So thank you very much for taking the time to reply. I do appreciate it.