The js output by PHP is not executed
alert('我弹出来了')"; ?>
You can output the JS script in PHP to the browser in one sentence implement. (Recommendation: "PHP Tutorial")
But today I encountered a very strange problem, that is, this code just outputs a string under Chrom and Firefox, and is not executed. An alert pops up.
Principle:
MIME chrome does not parsetext/plain. PHP can use header to output html, and the browser uses the last output header as content-type
header('Content-Type:text/html;charset=utf-8');
text/plainhtml will not be executed.
Just need to re-header before alert.
if(!uploadFile()) { echo ""; } header('Content-Type:text/html;charset=utf-8'); echo ("")
The above is the detailed content of What should I do if the js output by PHP is not executed?. For more information, please follow other related articles on the PHP Chinese website!