Unusual echo bug? What am I screwing up?
Posted: Wed Jul 26, 2006 9:10 am
I'm not sure if my problem is with SimpleXML (doubtful) or something goofy with the echo function but the following code snippet produces unusual results:
the xml file is here in case you need it:
The output:
Any help would be greatly appreciated.
-Chris
Code: Select all
<?php
$xml = simplexml_load_file("test.xml");
// Next line prints:
// Accepted Formats: ->format[0]
echo "Accepted Formats: $xml->formats->format[0]<br>\n";
$f0 = $xml->formats->format[0];
// Both of these work fine.
// Accepted Formats: Image
echo "Accepted Formats: $f0<br>\n";
printf("Accepted Formats: %s<br>\n", $xml->formats->format[0]);
?>Code: Select all
<?xml version='1.0' encoding='iso-8859-1'?>
<example>
<name>Example</name>
<formats>
<format ftype='1'>Image</format>
<format ftype='2'>Text</format>
</formats>
</example>Accepted Formats: ->format[0]
Accepted Formats: Image
Accepted Formats: Image
Any help would be greatly appreciated.
-Chris