Search the Community
Showing results for tags 'heredoc'.
Found 1 result
I'm a novice to PHP. What I want to do is add a new customer record to my XML database. It looks as if a simple way to do this would be to create a string using heredoc, which will insert the variable values, then turn it into a simpleXML object: $xml=simplexml_load_file("Test data.xml"); //load XML file // these $vars are all defined from form input in previous code $str= <<<EOS <!----> <customer> <cId>$Customer</cId> <organization>$organization</organization> <website>$URL</website> <contact>$name</contact> <email>$email</email> <phone>$phone</phone> <addr>$address</addr> <city>$city</city> <state>$state</state> <zip>$zip</zip> </customer> EOS; $new = new SimpleXMLElement($str); //turn $str into SimpleXML element $xml->addChild("customer",$new); //add it to DB My first question is whether DreamWeaver CS5 will allow me to do this. It gives me the "syntax error on line 1." Is it able to recognize heredoc? Second, am I approaching this the right way? I'm sure this is something that is done regularly for myriad websites, but I haven't found any clear direction on the best way to handle it. Finally, if this is the right approach, what am I missing to make it work?