为什么我的PHP代码转向评论?

时间:2016-03-20 19:58:38

标签: php html

我尝试将php写入我的html文件,即时通讯使用wampserver,但是当我在html中添加php时,它会转而评论为什么?请帮助。

$rand = rand();
// ...
$content2 = '<a href="http://example.net" title="Example 2" target="_blank"><img src="http://example.com/gallery/image-2.png?' . $rand .'" alt="Image 2" width="300" height="250" class="gallery-image"></a>';
// ...
$content = array($content1, $content2, $content3, $content4,);
shuffle($content);

转而发表评论

<?php 
echo "hello"

 ?>

1 个答案:

答案 0 :(得分:1)

您不会将PHP代码添加到HTML文件中。

如果文件包含PHP代码,则该文件需要具有有效的PHP扩展名,例如.php。 PHP文件也可以包含HTML代码。