PHP echo纯文本(PHP echo plain text)

编程入门 行业动态 更新时间:2024-10-24 08:21:55
PHP echo纯文本(PHP echo plain text)

我正在使用AWS Elastic Beanstalk并在其上使用php。

但是当我尝试回复一些html / javascript文本时,它只是打印出纯文本!

这是一个例子:

<?php public function testing (){ echo "<h1>Hello World !</h1>"; } ?>

给我这个 。

有关我正在使用api的信息,我的测试功能在http://xxx.eu-west-1.elasticbeanstalk.com/test/lavachart上调用

我真的不明白为什么没有解释html / javascript代码。

谢谢你的回答

I am working on an AWS Elastic Beanstalk and using php on it.

But when I try to echo some html / javascript text, it just get print me plain text !

Here's an example :

<?php public function testing (){ echo "<h1>Hello World !</h1>"; } ?>

Gives me this.

For information I am working with an api, and my testing function is called on http://xxx.eu-west-1.elasticbeanstalk.com/test/lavachart

I really can't understand why the html / javascript code isn't interpreted.

Thanks for answers

最满意答案

<?php header('Content-type:text/html; charset=UTF-8'); public function testing (){ echo "<h1>Hello World !</h1>"; } ?>

例如,你需要为你的php脚本响应正确的内容类型,如果这个html然后内容类型text / html。 但是你可能没有正确的配置服务器。 你可以在.htaccess文件或virtualhost配置中添加mime for php

AddType text/html .php <?php header('Content-type:text/html; charset=UTF-8'); public function testing (){ echo "<h1>Hello World !</h1>"; } ?>

for example you need response right content type for your php script, if this html then content type text/html. But you can have not right configuration server. you can just adding mime for php in you .htaccess file or virtualhost configuration

AddType text/html .php

更多推荐

本文发布于:2023-07-25 10:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1260016.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   echo   PHP   plain   text

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!