【问题标题】:How to make it so a PHP page is directed to the same page but with different variables如何使 PHP 页面定向到同一页面但具有不同的变量
【发布时间】:2014-06-09 01:42:19
【问题描述】:

我有一个日历,想在底部添加不同月份的链接,-1 月份和+1 月份在两端。我知道我需要使用 $_GET 方法才能获得特定的 URL。但是,我不确定我需要做什么才能让页面知道当它具有该特定 URL 时该做什么。

现在它只是一个../index.php URL。如果我尝试制作像index.php?day=02&month=01&year=2014 这样的扩展名,它只会显示默认页面。那么,如果用户要在 URL 中硬编码不同的月份或年份,您将如何做到这一点,它将引导他们到正确的日历月。

【问题讨论】:

  • 你当前的代码在哪里?

标签: php url methods get calendar


【解决方案1】:

类似:

<?php
$day = htmlspecialchars($_GET['day']);
$month = htmlspecialchars($_GET['month']);
$year = htmlspecialchars($_GET['year']);

if ($year == 2014) {
echo $day . $month . $year . " - This is the special Year Page! (would be a good idea to do an include here maybe?";
}

?>

这应该会给你一些关于如何实现你想要做的事情的想法。

【讨论】:

    猜你喜欢
    • 2011-06-26
    • 1970-01-01
    • 2022-01-21
    • 2015-10-22
    • 2011-12-29
    • 1970-01-01
    • 2014-10-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多