如何解决如何仅使用 get 方法参数在我的 php 中设置我的 URL 模式
我的目录 (/account) 中有 3 个 PHP 文件:
访问我本地主机中的文件夹:
http:localhost/account ==> 打开默认(index.PHP 文件)
我想访问 login.PHP 和 signup.PHP 使用:
=> http:localhost/account?login
和
=> http:localhost/account?signup
分别。
<?PHP
if($_GET['login']){
include('login.PHP')
} else {
// Load homepage of the site
// which in my case http://localhost
}
if($_GET['signup']){
include('signup.PHP')
} else {
// Load homepage of the site
// which in my case http://localhost
}
解决方法
您拥有登录和注册密钥但没有值,因此您应该使用 isset()
检查密钥是否存在。
<?php
if(isset($_GET['login'])){
include('login.php')
} else {
// Load homepage of the site
// which in my case http://localhost
}
if(isset($_GET['signup'])){
include('signup.php')
} else {
// Load homepage of the site
// which in my case http://localhost
}
如果您想改用 switch
,
switch(true) {
case isset($_GET['login']):
... break;
case isset($_GET['signup']):
... break;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。