使用内置服务器将一个php文件链接到另一个文件

问题描述 投票:0回答:1

我有一个文件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。但是在浏览器的URL栏中,它显示为“ http://localhost:8888/test.php”。

为什么不只加载test.php页面?我觉得我在服用疯药!

php
1个回答
0
投票

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

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

php -S localhost:8888
© www.soinside.com 2019 - 2024. All rights reserved.