我正在尝试创建后缀(名称是我所做的)。URL 爆炸器在下面..
private function explode_url() {
if (!empty($this->suffix) and empty($is)) {
// look here ------V
$url = explode('/', rtrim($_GET['url'], $this->define_suffix()));
} else {
$url = explode('/', trim($_GET['url'], '/'));
}
$str = '';
foreach ($url as $key => $value) {
if ($key >= 2) {
$str = $str . '/' . $value;
} else {
$data[] = $value;
}
}
$data[] = trim($str, '/');
foreach ($data as $data) {
if (!empty($data)) {
$result[] = $data;
}
}
return $result;
}
这是定义后缀的函数。
private function define_suffix() {
$count = count($this->explode_url()); // <------ look here
$count = $count - 1;
$keys = array('cnt', 'mtd', 'args');
return $this->suffix[$keys[$count]];
}
实际上功能很好,但有一个问题。有一个无限循环。我怎么能逃脱呢?
编辑:输出:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 130968 bytes) in /var/www/cleanmvc/boot.php on line 85
这些函数相互调用,这导致了无限循环。这就是我需要帮助的地方。