Jump to content

Problem with XML chapter in O'Reilly


Steven

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...