php calling html

  • 本文关键字:html calling php php
  • 更新时间 :
  • 英文 :


你能告诉我我缺了什么吗:

<html>
<head><title>page</title></head>
<body>
<h2><center>Welcome to the mainpage</center></h2><br />
<a href="sample4.php?currpage=2">Home page</a>
</body>
</html>

php代码为:

<?PHP
$currpage=$_GET['currpage'];

echo "Hello world $currpage"; 
?>

当我点击主页时,我希望执行sample4.php脚本,并显示作为html页面的输出。但当我点击致敬页面时:我会得到一个文件窗口下载。

我有php脚本在同一个位置我有html?

是否:

<html>
  <head>
    <title>My Page</title>
  </head>
  <body>
    <p><a href="sample3.php?currpage=2">Home page</a><p>
  </body>
</html>

做你想做的事?否则,您需要向我们展示PHP代码,以防它从PHP中下载。

对于hello world程序,请尝试以下操作:

<html>
  <head>
    <title>My Page</title>
  </head>
  <body>
  <?php 
    $currpage = isset($_REQUEST['currpage']) && is_int($_REQUEST['currpage'])?(int)$_REQUEST['currpage']:1;
    echo "<p>Current page is $currpage</p>n";
  ?>
  </body>
</html>

您可能还需要确保PHP已安装并在您的机器/服务器上运行。。。

<html>
  <head>
    <title>My Page</title>
  </head>
  <body>
  <?php 
    phpinfo();
  ?>
  </body>
</html>

最新更新