用php上的URL更改内容?

时间:2018-09-24 22:47:28

标签: php url

我有一个名为friend.php的文件,我想这样做来更改friend.php的内容:

friend.php?content=1, friend.php?content=2

在google上搜索时,我可以从url中找到更改元素,但是我想更改内容完整,例如具有content1.phpcontent2.php...,但表明仅使用url即可。

1 个答案:

答案 0 :(得分:2)

使用$_GET superglobal进行访问:

<?php
  if ($_GET["content"] == "1") {
    // show content1.php
  } else if ($_GET["content"] == "2") {
    // show content2.php
  }
?>