Home >Backend Development >PHP Tutorial >Illegal character replacement program_PHP tutorial
//************************************************ **********
//-- Program name: StrSwap V1.0
//-- Program purpose: Illegal data processing of Get or Post submitted values
//-- Remarks: This program needs to be loaded and used before all program processing, so that it can be automatically performed
//-- Replacement of variables used in the program
//************************************************ **********
class StrSwap{
//The connector used to connect variables when submitting variables in Get mode
var $GetSplitStr = "&&";
var $TempArray = array();
var $VariableArray = array();
//************************************************ **********
//-- Program name: Main()
//-- Program purpose: the default running mode of this class
//-- Incoming parameters: None
//************************************************ **********
function Main(){
global $REQUEST_METHOD;
if("GET"==$REQUEST_METHOD){
$this->SubGetStrToArray();
}
if("POST"==$REQUEST_METHOD){
$this->SubPostStrToArray();
}
$this->GlobalVariable();
}
//************************************************ **********
//-- Program name: SubGetStrToArray()
//-- Program purpose: The method called when the variable is submitted in Get mode
//-- Incoming parameters: None
//************************************************ **********
function SubGetStrToArray(){
global $QUERY_STRING;
$this->TempArray = explode($this->GetSplitStr,$QUERY_STRING);
for($i=0;$i
$temp = explode('=',$this->TempArray[$i]);
$this->VariableArray[$i][0] = $temp[0];
$this->VariableArray[$i][1] = $this->StrReplace($temp[1]);
}
}