|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-04-04 06:53 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 17:00:02 2025 UTC |
Description: ------------ Character coding mess... index.php and example.xml are saved in koi8-r encoding Reproduce code: --------------- index.php: <?php include 'example.xml'; $xml = simplexml_load_string($xmlstr); function open_linkset($num) { global $xml; eval("foreach(\$xml->linkset[$num]->mylink as \$mylink) { generate_link(\$mylink->title, \$mylink->href); }"); } function generate_link($title, $href) { global $link; $link[]='<a href="?'.$href.'&open='.$_GET[open].'">'.$title.'</a>'; } function generate_linkbox() { global $xml, $link; $i=0; $array_size=sizeof($xml->linkset); foreach($xml->linkset as $mylinkset) { echo '<a href="?open='.$i.'">'.$mylinkset->name.'</a>'; echo "<br>"; if(isset($link) && $_GET[open]==$i) { $k=0; $link_array_size=sizeof($link); foreach($link as $mylink) { echo " ".$link[$k]; if($link_array_size<>$k)echo "<br>"; $k++; } } $i++; } } if(isset($_GET[open])) { open_linkset($_GET[open]); generate_linkbox(); }else{ generate_linkbox(); } ?> example.xml: <?php $xmlstr = <<<XML <?xml version='1.0' encoding='koi8-r' standalone='yes'?> <linkbox> <linkset> <name>Главная</name> <mylink> <href>to=fotos</href> <title>Fotos</title> </mylink> <mylink> <href>to=art</href> <title>Art</title> </mylink> </linkset> <linkset> <name>Discussion</name> <mylink> <href>to=forum</href> <title>Forum</title> </mylink> <mylink> <href>to=guestbook</href> <title>Guestbook</title> </mylink> </linkset> </linkbox> XML; ?> Expected result: ---------------- Executing index.php I expect to see 2 linksets: Главная Discussion Actual result: -------------- The actual result after executing index.php: Главная Discussion