【问题标题】:Linking one php file to another with the built in server使用内置服务器将一个 php 文件链接到另一个
【发布时间】:2019-10-20 03:36:44
【问题描述】:

我有一个文件 index.php,它只有:

<a href="http://localhost:8888/test.php">Test</a>

我还有另一个文件 test.php,它只有:

<a href="http://localhost:8888/">home</a>

所以我的想法是,我可以在这两页之间来回移动。我通过输入加载它:

php -S localhost:8888 index.php

我可以得到索引页。但是当我单击“测试”链接时,它所做的只是重新加载 index.php。但在浏览器的网址栏中,却显示“http://localhost:8888/test.php”。

为什么不直接加载 test.php 页面?我觉得我正在服用疯狂的药丸!

【问题讨论】:

    标签: php


    【解决方案1】:

    由于您在命令行中指定了文件路径,the built-in web server will use it as a "router" script 并且无论如何都要获取它。

    省略它应该允许您浏览链接:

    php -S localhost:8888
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-17
      • 2020-11-10
      • 1970-01-01
      • 2013-07-15
      • 1970-01-01
      • 2019-12-19
      • 1970-01-01
      相关资源
      最近更新 更多