php标记不起作用/string不显示


php tags are not working/ string not displaying

我正在尝试用PHP编程,但PHP标记不起作用:我相信我下面的代码中没有错误:

<html>
    <head>
        <?php 
            $test = "Gumagana ako :P";
            echo "$test";
        ?>
        <title>My First PHP</title>
    </head>
    <body>
        My Test String is <?php echo $test; ">
    </body>
</html>

你认为问题出在哪里?仅供参考,我使用的是examplep。

确保您的文件扩展名是.php,并且位于Xampp文件夹的htdocs文件夹中。还要确保Apache服务运行良好。

还要确保,你浏览这个像http://localhost/yourfile.php

<html>
    <head>
        <?php 
            $test = "Gumagana ako :P";
            echo "$test";
        ?>
        <title>My First PHP</title>
    </head>
    <body>
        My Test String is <?php echo $test; ?>
    </body>
</html>

您在关闭php时出现了拼写错误。

My Test String is <?php echo $test; ">

像这样关闭你的php:

My Test String is <?php echo $test; ?>

否则,php会尝试将以下内容解释为php,从而产生错误:

"> </body> </html>

缺少PHP结束标记,或者问题已被双引号替换:

 My Test String is <?php echo $test; ?>
  <body>

       My Test String is <?php echo $test; ">

  </body>

有误

My Test String is <?php echo $test; ?>

请检查

这样写:-

My Test String is <?php echo $test;?>

My Test String is <?php echo $test; ?>//标签未关闭