我正在使用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更多推荐
发布评论