我现在正在编写脚本,我有一个名为ban.php
的PHP文件,其想法是禁止IP。我有一个名为Banning
的课程,它位于inc/class.Banning.inc.php
内。由于有禁止单个IP地址和IP范围的能力,我决定请求$_GET
。例如:ban.php?type=single
将加载单个IP地址的表单,并且ban.php?type=range
将加载IP范围的表单。不确定为什么我的班级功能无法正常工作
这是禁止类:
/**
* BANNING CLASS
*/
class Banning {
/**
* VARIABLES
*/
private $_Gtype;
private $_G_Result;
/**
* Constructor, set variables to ban.php $_GET
*/
public function __construct() {
$this->_Gtype = isset($_GET['type']) ? $_GET['type'] : null;
}
/**
* GET THE BANNING TYPE FROM $_GET IN BAN.PHP
*/
public function getType() {
// Get the type of banning form from $_GET
if ($this->_Gtype == 'single') {
$this->_G_Result == 'single';
} else if ($this->_Gtype == 'range') {
$this->_G_Result == 'range';
}
// Return the value
return $this->_G_Result;
}
}
然后在我ban.php
文件我有以下几点:
require_once('inc/class.Banning.inc.php');
define('BAN_IP', true); // define the ban constant
/**
* DETERMINE WHICH FORM TO DISPLAY REGARDING $_GET
* Making use of the getType() function in Banning Class.
*/
$getType = new Banning();
if ($getType->getType() == 'single') {
require_once('html/ban.single.php');
}
?>
<style type="text/css">
<?php require_once('css/css.css'); ?>
</style>
我有错误,在我的httpd.conf
文件打开,我上运行此我的Mac(MAMP)。 当我运行页面ban.php?type=single
我留下一个空白页面。我做了什么有什么不对吗?
不确定,但不应该'ban.php?type = single'是'ban.php?_Gtype = single'或'ban.php?Gtype = single'? –
@ Fred-ii- Gtype变量被分配给构造函数中的$ _GET ['type']。 –
对不起,我的错。 –