What should I do if the js output by PHP is not executed?

angryTom
Release: 2023-02-28 11:04:02
Original
3616 people have browsed it

What should I do if the js output by PHP is not executed?

The js output by PHP is not executed

alert('我弹出来了')"; ?>
Copy after login

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');
Copy after login

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 ("")
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!