AngelicOne Posted July 17, 2011 Share Posted July 17, 2011 Hello there. This is my first post here in w3school's forum and would like to take this opportunity to say THANKS FOR EVERYTHING because you made me who I am today. :)I'm having a great time reading and trying out the tutorials but there are a couple of things that doesn't seem right or confusing in PHP.The first I noticed was the PHP do..while loop tutorial. The description says "The example below defines a loop that starts with i=1. It will then increment i with 1, and write some output. Then the condition is checked, and the loop will continue to run as long as i is less than, or equal to 5", but the output of the code was this The number is 2The number is 3The number is 4The number is 5The number is 6It should stop the loop when it becomes equal to 5, right? Then why did it stop at 6?Second, the XML Expat Parser in PHP is quite confusing. The case match for switch statement to execute a function for starting elements doesn't work if it's LOWERCASE. UPPERCASE works even though my tag elements in xml are lowercase.function start($parser,$element_name,$element_attrs) { switch($element_name) { case "NOTE": echo "-- Note --<br />"; break; Doesn't workcase "note":Another thing, I came across at a weird problem about the "stop" or "end" function for xml_set_element_handler. I did spend lots of time just to find out myself that a function that is named end doesn't work(function end()). Am I right? Link to comment Share on other sites More sharing options...
Ingolme Posted July 17, 2011 Share Posted July 17, 2011 The reason the loop can output 6 is because the condition to enter the loop is that $i is less than or equal to 5. Inside the loop $i begins being equal to five, but then 1 is added to $i and finally $i is printed, displaying a 6 before the loop terminates.I haven't worked with the XML Expat parser, I usually use the DOMDocument class instead, so I'm not sure why element names are returned in uppercase. Link to comment Share on other sites More sharing options...
trevelluk Posted July 18, 2011 Share Posted July 18, 2011 By default then the XML parser will convert all element names to uppercase. You can change this with the xml_parser_set_option() function. See http://uk3.php.net/manual/en/function.xml-...-set-option.php Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.