Php Newbie, echo not working?

和自甴很熟 提交于 2020-01-08 06:37:05

问题


So this is almost definitely a newbie question, but I'm going through the w3 tutorial on php and on my server I can only get echo to work sometimes.

For example in one trial they have me submitting inputs in one form and picking them up in another, and echo works in that case, but in this code it won't:

<html>
<body>

<p>
This should work!! <?php
$str = "Hello, World!";
echo $str; 
?>
It failed...
</p>

</body>
</html>

The output should just be: This should work!! Hello, World! It failed... But instead it just returns This should work!! It failed..., to the html page when I look at it.

Any ideas on how I could possibly get this to work?


回答1:


I suppose that you have forgotten to let the filename end with .php.

So everything between the <(?php) and the (?)> is interpreted as a html tag and not visible. See your raw html output, then you may notice what's going on.



来源:https://stackoverflow.com/questions/16253891/php-newbie-echo-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!