问题
My free webhost appends analytics javascript to all PHP and HTML files. Which is fine, except that I'm using nuSoap to create a WSDL file for a webservice I'm working on. My darn host adds this to my php-generated WSDL file.
Some people have suggested add this to the .htaccess file:
AddType text/xml .php
Which is dandy, but it disables the PHP engine as well, and there's no way to generate the WSDL then.
I've searched everywhere, no luck. Webhost does not respond to emails or support tickets either.
Edit: The script my webhost uses is Histats. Published by Histats.com. Also, this JavaScript block falls outside the <html></html>
tags and won't pass validator.
回答1:
As per @Gerben's comment...
Adding <!--
does not work. The host already starts their extra stuff with a comment, and the -->
that follows gets overridden.
Adding header('Content-Type: text/xml');
does nothing, the javascript still shows.
HOWEVER! We've found the answer... putting exit();
at the end of the PHP script will disable this function!
As a side note to Mr. @Gerben -- Thank you, and I've voted up one of your other answers, so you get credit for this...
来源:https://stackoverflow.com/questions/9050433/disable-statistics-analytic-javascript