December 19th, 2014, 06:05 AM
Sitemap.php - Ampersand and cache
I've created a sitemap.php and following the recommendations of "sitemap protocol" I added this class to the urls.
And applied it as such:
// This is the protocol required for the XML in sitemap.php
$string = str_replace("&","&",$string);
$string = str_replace("'","'",$string);
$string = str_replace('"','"',$string);
$string = str_replace(">",">",$string);
$string = str_replace("<","<",$string);
However, if I cut a url from the sitemap.xml such as:
echo '<loc>'.cleanMAP($url).'</loc>'. PHP_EOL;
And post it in a browser,
I get this?
I've looked at "other" sitemap's and they don't convert & to & but that's besides the point?
Warning: fopen(cache/): failed to open stream: No such file or directory in C:\xampp\htdocs\demo\includes\functions.php on line 138
Warning: fputs() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\demo\includes\functions.php on line 139
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\demo\includes\functions.php on line 140
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\demo\templates\black_star\blog_entry.php on line 49
So my question is:
Do the spiders reiterate the url as & - Or are they going to run into a brick wall of errors - because it all works fine if I alter the url & to &?
And the other thing is - I can't possibly see how to "clean" the url request to access the cached information.
And if it will make it easier - I'll post the sitemap.php here if requested.
December 19th, 2014, 04:21 PM
Encoding the & as &s is about making the content (the URL) safe for where you're putting it (the XML). When anybody reads the XML content as XML they'll get the decoded version back; you simply copied what you saw in the file and that's not the same thing.
You should fix those warnings in your code. They hint at larger problems that may leave your site unsafe.
December 19th, 2014, 06:48 PM
And for pointing out yet another error which seems to have multiplied since upgrading to php5*