Steven Posted June 3, 2008 Share Posted June 3, 2008 I'm going through the Learning PHP 5 book from O'Reilly and am trying out some of the XML chapter. I wrote down the code exactly (I think), but it isn't returning anything when I uploaded it (yes, my host has PHP). Here's the code: <?php$channel =<<<_XML_ <channel> <title>What's for dinner</title> <link>http://menu.example.com/</link> <description>These are your choices of what to eat tonight.</description> </channel>_XML_;$xml = simplexml_load_string($channel);print "The $xml->title channel is available at $xml->link. ";print "The description is \"$xml->description\"";?> The code acts like <title>What's for dinner</title> is a string, so in Dreamweaver it turns all of the code after the ' to red. Any ideas? Link to comment Share on other sites More sharing options...
Jesdisciple Posted June 3, 2008 Share Posted June 3, 2008 Don't bother with what Dreamweaver thinks of the code in such a case if Dreamweaver doesn't recognize heredocs. What content does the server output? If the server has no problem with it, Dreamweaver doesn't recognize heredocs.EDIT: Sorry, I forgot the first part of your message. You say it doesn't return anything? Try adding this to the top and report the output: error_reporting(E_ALL | E_STRICT); Link to comment Share on other sites More sharing options...
aszxcv Posted June 3, 2008 Share Posted June 3, 2008 i have same bookso when i get to that part this thread may be some help Link to comment Share on other sites More sharing options...
Steven Posted June 3, 2008 Author Share Posted June 3, 2008 Strange, even after placing "error_reporting(E_ALL | E_STRICT);" it prints nothing.aszxcv- What do you think of the book so far? Link to comment Share on other sites More sharing options...
Jesdisciple Posted June 3, 2008 Share Posted June 3, 2008 Keep the error_reporting line and add this to the top of your XML: <?xml version="1.0" encoding="ISO-8859-1"?> Anything now?EDIT: And in the interest of keeping the forum clutter-free, that conversation would probably be more appropriate in a PM. Link to comment Share on other sites More sharing options...
aszxcv Posted June 3, 2008 Share Posted June 3, 2008 Strange, even after placing "error_reporting(E_ALL | E_STRICT);" it prints nothing.aszxcv- What do you think of the book so far?it seem a bit outdated but i am a newbie to php so i cant fuss better to learn at least basic Link to comment Share on other sites More sharing options...
justsomeguy Posted June 3, 2008 Share Posted June 3, 2008 When you're using object properties in a string you'll want to surround them with brackets.print "The {$xml->title} channel is available at {$xml->link}. "; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.