I’m currently writing out xml and have done the following:
header ("content-type: text/xml");
header ("content-length: ".strlen($xml));
$xml being the xml to be written out. I’m near about 1.8 megs of text (which I found via firebug), it seems as the writing is taking more time than the script to run.. is there a way to increase this write speed?
Thank you in advance.
It really depends on how you’re writing the data. If you’re using DOM, consider XMLWriter. It’s a bit faster and more streamlined.
If you’re homebrewing your XML output, ensure that you aren’t appending strings unnecessarily. For instance:
The comma operator doesn’t create new strings. Also to consider, single quoted strings are slightly faster than double quotes. There is no variable substitution to scan for. Normally, the difference is minimal, but in a tight loop you can definitely see it.
Depending on your data source and how you construct your XML, your processing might be the bottleneck. Try profiling with xdebug and seeing where your bottlenecks actually are.