2015.03.09-PHP obtains HTTP request information, the scope of variables in PHP, Jquery review, the use of Session in PHP

Today's tasks:
1. Enterprise information query and modification
2. Employee information query

Actual :
1 and 2 are completed

Gain :
1. The method and type of HTTP request can be judged in PHP: $_SERVER['REQUEST_METHOD'] // GET POST DELETE, etc.; $_SERVER['HTTP_X_REQUESTED_WITH'] // XMLHttpRequest, that is, ajax request
2. In PHP, if a file is not a class, it has variables and methods. When calling a method, if the variable needs to be processed inside the method, it must be passed in by means of parameters.
3. Review the JQuery method, such as $(".xxx").attr("src", "xxlsdfsdf");
4. Detect php session
if (!isset($_SESSION)) {
    session_start();
}
if (!isset($_SESSION['id'])) {
    header ("Location: " . WEB_ROOT . "index.php");
    return ;
}
$timeout=1200; //Timeout time, unit: seconds, here is set to 20 minutes.
$now = time();
if(($now-$_SESSION['session_time'])>$timeout)
{
// timed out.
unset($_SESSION['id']);
header ("Location: " . WEB_ROOT . "index.php");
return;
}else{
// haven't timed out yet.
$_SESSION['session_time']=$now;
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327041790&siteId=291194637