print/echo'显示结束标记-或者不输出


PHP - 'print/echo' displaying closing tags - or not outputting

刚开始学习PHP,对echo/print的工作方式感到困惑。

我在我的index.html中有这个代码:

<?php
Print '<div>Hello, World!</div>';
?>

我页面上的输出是

Hello, World!'; ?> 

如果我删除<div>标签,我没有得到输出。使用echo产生相同的行为。

怎么回事?我在谷歌上找到的所有东西都让它看起来很直接。

你不能把PHP代码放在HTML文件中(除非你告诉Apache解析HTML文件)。

重命名为index.php

你有一个PHP设置的web服务器吗?