Edit report at https://bugs.php.net/bug.php?id=55774&edit=1
ID: 55774
Updated by: danack@php.net
Reported by: inge at upandforward dot com
Summary: Array index limitation
-Status: Open
+Status: Feedback
Type: Bug
Package: Scripting Engine problem
Operating System: php 5.3.5-1ubuntu7.2
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Hi Inge,
It does mean that there is something different between your local server and the expected behaviour.
If this is still occuring, please can you provide some information about what the difference is
between your local server and webserver.
Previous Comments:
------------------------------------------------------------------------
[2011-09-25 09:05:28] inge at upandforward dot com
The original code, using "basename", only fails on my local server, NOT when executed on
my webhost.
That should conclude that this is not a PHP bug?
------------------------------------------------------------------------
[2011-09-25 09:00:50] inge at upandforward dot com
For now I have made a work-around which works in all cases, using this function:
function name_only($file)
{ $from[] = '.'.substr(strrchr($file,'.'),1);
$from[] = dirname($file).'/'; // Remove extension and path.
return str_replace ($from,'',$file);
}
------------------------------------------------------------------------
[2011-09-25 08:37:08] inge at upandforward dot com
I think I have found the problem, but no solution. The following test script functions perfectly
when run stand-alone, but "basename" fails when run from Apache 2.0.
Are you able to reproduce the error?
<?php
define ('PT' , '.'); // (Decimal) point
define ('LF' , PHP_EOL); // File newline
$charset = 'utf-8'; // NB! Select charset here!
define ('CHARSET',$charset); // NB! Define it as a constant.
setlocale(LC_ALL, 'nb_NO');
mb_internal_encoding (CHARSET);
putenv ("LANG=nb_NO.".CHARSET);
$filenames = array
("php/Treffer.php","php/Ãvinger.php","php/Ãsop.php");
$destinations = array();
// Save all info for each file. This means that we won't have to
foreach ($filenames as $file) // search any more.
{ $key = basename($file,".php");
$destinations[$key] = $file;
}
echo "After: ".print_r($destinations);
?>
------------------------------------------------------------------------
[2011-09-25 07:41:06] inge at upandforward dot com
You are right. This was a case of jumping to conclusions.
The value used as a key was already wrong, and I should have checked that.
The problem is associated with the function basename, but I have also not been able to reproduce
this in a standalone script, so it must be a side-effect from something else. I need to investigate
further.
Sorry to have bothered you. I really thought I had done enough testing! :)
------------------------------------------------------------------------
[2011-09-24 18:58:15] aharvey@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
I can't reproduce this at all in a standalone script:
http://codepad.viper-7.com/pZswtF shows an example
of a UTF-8 encoded
array key being set properly. (I wrote another test that persists a
similar array key across multiple pages via $_SESSION, and that worked
as expected too.)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=55774
--
Edit this bug report at https://bugs.php.net/bug.php?id=55774&edit=1