【发布时间】:2016-07-29 12:50:34
【问题描述】:
我收到 PHP 通知错误。这段代码在 php 5.3 中运行良好,但后来我将 PHP 升级到 PHP 7。我想做的是,从链接中获取 URL,然后只显示 URL 附带的参数。这是代码。
index.php
<?php
require_once('bootstrap.php');
$bootstrap = new Bootstrap($_GET);
?>
bootstrap.php
<?php
class Bootstrap{
private $controller;
private $action;
private $request;
public function __construct($request){
$this->request = $request;
if($this->request['controller'] == ''){
$this->controller = "Home";
}
elseif($_GET($request['controller'])){
$this->controller = $this->request['controller'];
}
if($this->request['action'] == ''){
$this->action = "index";
} else{
$this->action = $this->request['action'];
}
echo "<br />$this->controller<br />$this->action";
}
?>
转到 URL 时的输出:localhost/myDir/index.php/abc/def
注意:未定义索引:第 8 行 /srv/http/myDir/bootstrap.php 中的控制器
注意:未定义索引:第 14 行 /srv/http/myDir/bootstrap.php 中的操作
首页
索引
【问题讨论】:
标签: php compiler-errors get notice