Step by step build your own lightweight mvcphp frame-(iii) a homegrown lightweight framework Amysql Source Analysis (2) process

Source: Internet
Author: User
Tags php error

Amysql class According to my understanding this is the initialization of the framework

On the Code

classAmysql { Public $AmysqlProcess;  Public functionAmysql () {Global $Config; Ini_set("Magic_quotes_runtime",false); ($Config[' debugphp '] &&error_reporting(E_all)) ||error_reporting(0);//whether to error($Config[' Sessionstart '] &&Session_Start());//SESSION(!Empty($Config[' CharSet ']) &&Header(' content-type:text/html;charset= '.$Config[' CharSet '])); }    Static  Public functionAmysqlnotice ($notice)    {        $AmysqlController=NewAmysqlcontroller (); $AmysqlController-notice =$notice; include(_amysql. ' Amysqlnotice.php '); Exit(); }    Static  Public functionFilter (&$array,$function)     {        if(!Is_array($array))Return $array=$function($array); foreach($array  as $key=$value)             (Is_array($value) &&$array[$key] = Amysql::filter ($value,$function)) ||$array[$key] =$function($value); Return $array; }}

This class contains a public attribute amysqlprocess and three functions including constructor Amysql

First, Amysql (): This function is the constructor of this class, in fact, according to the current notation is __construct ().

①magic_quotes_runtime: The effect is to transfer the externally introduced special characters [single quotation mark ('), double quotation mark ("), backslash (\) and NUL (NULL character)] plus a backslash, but this is deprecated in php5.3 and is not recommended.

②error_reporting: Set PHP error level

/* ERROR level
* Fatal error Fatal: 1
* Warning Warning Error: 2
* NOTICE Warning: 8
* All open: 11
* Close all: 0
*/

③ Explain && | | ,&& is to require that the identifier be true before and after, | | It is true that there is one before and after it.

When $Config [' debugphp '] is true then && will continue to execute error_reporting (E_all), set the error level to show all errors, and | | The previous has been executed, then the back will not be executed again. When $config[' debugphp ' is False | | The front is false, so the following error_reporting (0) will be executed to set the error display level to not display an error.

Second, Amysqlnotice (): This function is to display the error prompt

① in this case the object created with the Amysqlcontroller class Amysqlcontroller did not discover what the egg is for.

② introduces an external file, amysqlnotice.php, which is a piece of HTML code that displays an error prompt, and the trailing exit is used to stop the script from running after the error message is output.

Here is the error prompt HTML code, there is no analysis of the ~o (∩_∩) O haha ~

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><title></title><styletype= "Text/css">Body{margin:0px;}#confirm{background:Rgba (125,125,125,0.4);Filter:progid:DXImageTransform.Microsoft.Gradient (startcolorstr= #40000000, endcolorstr= #40000000);width:500px;margin:30px auto 0px auto;Border:Solid 1px #666;Border-radius:3px;}#confirm #inside{background:#FFFFFF;margin:5px;Height:230px;Border-radius:3px;}#confirm #inside H1{margin:0px;font-family:Verdana, Geneva;font-size:13px;padding:5px 10px;Background-color:#f0f0f0;Border:Solid 1px #ddd;Display:Block;}#confirm #inside #content{width:300px;margin:25px auto 0px auto;Line-height:30px;font-size:15px;font-family:Verdana, Geneva, Sans-serif;}</style></Head><Body><DivID= "Confirm">  <DivID= "Inside">    <H1>Error hints</H1>    <DivID= "Content"><Center><?php echo $notice?></Center></Div>  </Div></Div></Body></HTML>

Three, filter (& $array, $function): This function is to use $function this variable represents the function will $array this variable represents the value to be converted.

Like what:

Amysql::filter ($_get, ' addslashes ')

The code is to escape the value of the $_get variable using addslashes (). This function internally $array the array to determine whether recursive calls are made to make further conversions.

This is an analysis of the Amysql class, and the next section continues to describe the Amysqlprocess general Process object class

Step by step build your own lightweight mvcphp frame-(iii) a homegrown lightweight framework Amysql Source Analysis (2) process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.