[英]Print HTML Response with localhost cUrl - Linux
I want to execute PHP Script on my Ubuntu Virtual Machine but I only have access to the command line. 我想在我的Ubuntu虚拟机上执行PHP脚本,但是我只能访问命令行。 I've thought about using cUrl but I have a problem with it :
我曾经考虑过使用cUrl,但是我有一个问题:
When I use the following command : "curl http://localhost/myscript.php " 当我使用以下命令时:“ curl http://localhost/myscript.php ”
The response is the plain file (" <?php echo "<p>Hello world</p>"; ?>
") instead of html response (" <p>Hello world</p>
") 响应是纯文件(“
<?php echo "<p>Hello world</p>"; ?>
”)而不是html响应(“ <p>Hello world</p>
”)
How to solve this problem ? 如何解决这个问题呢 ?
Thank you 谢谢
You may have to set the content-type using header(). 您可能必须使用header()设置内容类型。
Before the echo statement, insert this: 在echo语句之前,插入以下内容:
header('Content-Type: text/html');
See: http://php.net/manual/en/function.header.php 请参阅: http : //php.net/manual/en/function.header.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.