PHP's awesome face question sharing _php skills

Source: Internet
Author: User
Tags call back explode mysql query php mysql php mysql query rand sqlite csrf attack
What kind of network protocol does 1.nginx use?


Nginx is the application layer I think from the bottom up, the transport layer uses the TCP/IP application layer for HTTP


FastCGI is responsible for the scheduling process








2. ? echo ' Hello Tusheng ';?> has no output, what might be the reason, the process of solving this problem briefly (hint: syntax is not a problem)








may not have a short label on the server Short_open_tag = set to Off,,php.ini to open a short label control parameter: Short_open_tag = on








3. Briefly describe the output of the following program, and briefly explain why, how to solve such problems?


<?php


$tmp = 0 = "a"? 1:2;


Echo $tmp;


?>








result 1 int and string type cast, 0=== "a"








0 = 0 must be true


PHP is a weak type.


$tmp = 0 = = "a"? 1:2;


Echo $tmp; This is 2
.













4. A string is known as follows: $str = "1109063 Milo 1";


the 1109063 assignment to $uid in a line of code, Milo assignment to $user, 1 assigned to $type








spaces are as follows


List ($uid, $user, $type) = Explode ("", $str);


\ t follows


list ($uid, $user, $type) = Explode ("T", $str);








list ($uid, $user, $type) = sscanf ($str, "%d%s%d");








$n = sscanf ($auth, "%d\t%s%s", $id, $first, $last);








5. Lists the following types of signed and unsigned range TINYINT SMALLINT mediumint INT








tinyint-2^7-2^7-10 ~ 2^8-1


smallint-2^15-2^15-1 0 ~ 2^16-1


mediumint-2^23-2^23-1 0 ~ 2^24-1


int-2^31-2^31-1 0 ~ 2^32-1








6. Assemble the following array in one line as a string I am milo! Day Day up!


<?php


$arr = Array (


' I ', ' AM ', ' milo! ', ' Day ', ' Day ', ' up! '


);


?>








$str = Strtolower (Implode ("", $arr));








7. Call the following function to get the function and get the value of Count


<?php


function get_list ($cnd = Array (), & $count = False)


{


//Pseudocode handles $CND and assigns value datas


$datas = ' I am call back ';


$count && $count = rand (1, 10000);


return $datas;


}


?>








$count = 1;


$data = get_list ($cnd,& $count);


Echo $count;








8. Several ways to replace the session mechanism, a simple description of their pros and cons








MySQL, memcache, cookies keep a unique status identification code








9. The following HTTP status codes appear as possible causes and how to handle


200, 301, 404, 502, 503








200

The
request was successful and the response header or the data body that the request expects will be returned with this response.


301


The requested resource has been permanently moved to the new location, and any future references to this resource should be one of several URIs returned with this response. If possible, clients with link-editing capabilities should automatically modify the requested address to the address returned from the server.   Unless otherwise specified, this response is also cacheable. The new permanent URI should be returned in the Location domain of the response.   Unless this is a head request, the responding entity should contain a hyperlink to the new URI and a short description.   If this is not a get or head request, the browser prohibits automatic redirection unless the user confirms it because the condition of the request may change. Note: For some browsers that use the HTTP/1.0 protocol, the next redirection request becomes a get mode when the POST request they send gets a 301 response.








404

The
request failed, and the requested resource was not found on the server. There is no information to tell the user whether the situation is temporary or permanent. If the server knows the situation, it should use a 410 status code to inform the old resource because of some internal configuration mechanism problems, is permanently unavailable, and there is no address to jump. 404 This status code is widely used in situations where the server does not want to reveal exactly why the request was rejected or if no other appropriate response was available.


502


An invalid response was received from the upstream server when a server working as a gateway or proxy attempted to execute a request.


503


the server is currently unable to process requests due to temporary server maintenance or overloading. This condition is temporary and will be restored after a period of time. If the latency can be predicted, then a retry-after header can be included in the response to indicate the delay time.   If this retry-after information is not given, the client should handle it in a way that handles 500 responses. Note: The presence of a 503 status code does not mean that the server must use it when it is overloaded. Some servers simply want to deny client connections.














OK all right, the answer document for Get and post requests follows.


Moved permanently customer requested document elsewhere, the new URL is given in the location header, and the browser should automatically access the new URL


404 Not Found Cannot find the resource at the specified location. This is also a common answer.


502 Bad Gateway server, as a gateway or proxy, accesses the next server in order to complete the request, but the server returns an illegal reply.


503 Service Unavailable Server failed to answer due to maintenance or overload. For example, a servlet might return 503 if the database connection pool is full. The server can provide a retry-after header when it returns 503.








10. Have the following database, with the original eco-MySQL extension to connect and query the user table of the first 10 lines


host:192.168.0.254


port:3306


User:one


pass:piece


Database:db_user


Table:user








$link = mysql_connect ("192.168.0.254:3306", "one", "piece") or Die (' could not connect: '. Mysql_error ());


mysql_select_db (' Db_user ', $link);


$query = mysql_query ("SELECT * from User limit 10");


while ($rs = Mysql_fetch_array ($query, MYSQL_ASSOC))


{}








11. AutoLoad ($class) implements the automatic loading of classes under the Lib directory and can be compatible with subdirectories


$request->action = Lcfirst (implode array_map (


' Ucfirst ',


explode ('-', Strtolower ($request->action))


)));


------------------------------------------------------------


function __autoload ($class)


{


$cls = Strtolower (Str_replace ("_", "/", $class));








if (file_exsits (LIB. $cls. '). php '))


{


include_once (LIB. $cls. ') php ');


}


Else


{


die ("not Found {$class} class");


}


}


defined ("LIB", '/data/wwwroot/www.xx.com/lib/');


$author = new Lib_author ();


-----------------------------------------------------------


function __authload ($class)


{


$cls = Explode ("_", $class);


if (@is_dir ($cls [1])


{


if (@is_file ($cls [2])


{


include_once ("Con_path". $cls [1]. ' /'. $cls [2]. ". PHP ");


}


Else


{


dir (' Error ');


}


}


Else if (@is_file ($cls [1]. ". PHP))


{


include_once ("Con_path". $cls [1]. ". PHP ");


}


Else


{


dir (' Error ');


}


}


---------------------------------------


function __autoload ($class)


{


$cls = Explode ("_", $class);


$file = Get_file ($CLS);


if ($file = = ' ERROR ')


{


die (' Error ');


}


include_once ($file);


}


function Get_file ($dir)


{


if (Is_array ($dir))


{


foreach ($dir as $k => $v)


{


$tmpdir. = $v. '/';


if (is_dir (' Con_path '. $tmpdir))


{


continue ();


}


Else if (is_file (' Con_path '. $tmpdir.) PHP))


{


return ' Con_path '. $tmpdir. " PHP ";


}


Else


{


return ' ERROR ';


}


}


return ' ERROR ';


}


return ' ERROR ';


}








defined ("Con_path", "/data/wwwroot/www.xx.com/app/cntroller/");


$SB = new CONTROLLER_SB ();


------------------------------------


function __autoload_my_classes ($classname)


{


# Your logic to include classes here


}


spl_autoload_register (' __autoload_my_classes ');


-----------------------------------------------------------


12. With Set_error_handle to catch errors and output, the level of their own set


Set_error_handle (callback,level)


function Callback (int $errno, String $errstr [, String $errfile [, int $errline [, array $errcontext]]] {


}








function Dealerrorhandler ($errno, $errstr, $errfile, $errline)


{


switch ($errno) {


Case E_user_error:


echo "error [$errno] $errstr fatal error on line $errline in file $errfile";


break;


Case e_user_warning:


echo "My warning [$errno] $errstr":


break;


Case E_user_notice:


echo "My notice[$errno] $errstr";


break;


Default:


echo "UNKONWN error type: [$errno] $errstr";


break;


}


}


Set_erro_handler (Dealerrorhandler);








trigger_error ("notice", e_user_notice);


trigger_error ("Warning", e_user_warning);


trigger_error ("error", E_user_error);








13. A brief description of two kinds of notice warning methods for blocking PHP programs








Initialize the variable, the file starts setting the error level or modifies the php.ini settings error_reporting


Set_error_handler and @ suppression error








1. Add in the program: error_reporting (E_all & ~e_notice);








2. Or modify php.ini: error_reporting = E_all








changed to: error_reporting = e_all & ~e_notice


3.error_reporting (0) or modify Php.inidisplay_errors=off














14. The role of instanceof, often in what design mode to use








A single case pattern, but other patterns will also be used for








15. 1023 in binary notation and a brief description of the computational process








10-2


1023%2=1


511%2 = 1


255%2 = 1


127%2 = 1


63%2 = 1


31%2 = 1


15%2 = 1


7%2 = 1


3%2 = 1


1%2 = 1


0 = 0


-------------------------------------------


1023


2^9=<n<2^10


511








k=9


10 9 8 7 6 5 4 3 2 1


1 1 1 1 1 1 1 1 1 1


----------------------


1023 1


1023-1/2=511 1


511-1/2=255 1


255-1/2=127 1


127-1/2=63 1


63-1/2=31 1


31-1/2=15 1


15-1/2=7 1


7-1/2=3 1


3-1/2=1 1














-----------------------------------------------








2-10








Just start with the number on each bit of the binary number from the far right, the first number on the right is multiplied by the number of 0 times two, the second is multiplied by the second, the third is multiplied by the two of the second, and then the number of n is multiplied by the second (n-1), and then the resulting result is added to the


Example: 110011=1*2^0+1*2^1+0*2^2+0*2^3+1*2^4+1*2^5=51


This can also be regarded as a formula is an*2^ (N-1) an represents the binary number of the rightmost start of the number of nth,


the first item, the third item, to the nth term by using an an*2^ (n-1) and adding it together














16. What is the output of the following PHP program? Why?


<?php


$str = "AA\TBB\TCC";


@list ($a, $b, $c) = explode (' t ', $str);


echo $a, $b, $c;


?>








aabbcc;//' t ' will not cut the string with \ t, explode after the Shanghai an array (0=> "AA\TBB\TCC") so ... , ' t ' changed to ' t ' to be cut








17. What error levels are returned by include and require respectively








include system warnings and continues execution, require will issue a system warning but will cause a fatal error to terminate the script








18. There is a function that has an indeterminate number of arguments (there may be 5 or 50), and how to define the function


method One: Do not use PHP built-in function


method Two: Hint Func_num_args () Func_get_arg () Unc_get_args ()














function param ()


{


$numargs = Func_num_args ();


echo "Number of arguments: $numargs <br/>\n";


if ($numargs >= 2) {


echo "Second argument is:". Func_get_arg (1). "<br/>\n";


}


$arg _list = Func_get_args ();


for ($i = 0; $i < $numargs; $i + +) {


echo "Argument $i is:". $arg _list[$i]. "<br/>\n";


}


}








param (1,2,3,4,5);














/**


2 * Example after writing, originally thought that finished, the result met someone asked Call_user_func_array (), looked at the manual


3 * Originally, the test function above can also be condensed into the following example,


4 * *


5 function Otest1 ($a)


6 {


7 echo (' one parameter ');


8}


9


function Otest2 ($a, $b)


11 {


Echo (' two parameters ');


13}


14


function Otest3 ($a, $b, $c)


16 {


Echo (' three ");


18}


19


function otest ()


21 {


$args =func_get_args ();


$num =func_num_args ();


call_user_func_array (' otest '. $num, $args);


25}


26


otest (1,2);
































19. In a function (the function has no return statement) inside to handle the global variable, and change his value, in two ways to implement (Global and Reference &)








$var = 1;


function Get_pra ()


{


Global $var;


$var = ' xxx ';


Echo $var;


}


echo $var. '--';


Get_pra ();


Echo $var;


----------------------------------


$test = 1;


$test 1 = 2;


function Get_yinyong ()


{


Global $test 1;


$GLOBALS ["Test"] = & $test 1;


}


echo $test. " \ n ";


Get_yinyong ();


Echo $test;


----------------------------


20. In the application we often encounter in the user table randomly tuned 10 data to display the situation, briefly describe how you implement the function, you can not use SQL functions and statements


table User Field UID, username








estimates a user table in the interval, in this interval with PHP to a random number, the SQL statement is greater than or less than this ID to limit dozens of (to ensure 10 data), and then not enough scattered words, take out the data shuffle function to disrupt the array, Array_ Rand immediately takes out 10








21. Let's say the UID in the following SQL statement gets a specific value, and after the following statement query the order of the UID, how to sort by the order of the UID in input


Select uid from user where UID in (10, 1, 3, 8, 11, 4, 7);








considerable result is 1,3,4,7,8,10,11 ascending, there is a special situation is not sure because some of the middle of the ID of the direct modification may not be ascending, if the order in the UID in sequence needs to be recycled according to the ID to get the value of the query results array into the new array can be








22. Use PHP to replace the letters in a string with * *








preg_replace ('/[a-za-z]*/', ' * * ', $STR);


if the specified character can be str_replace (' Ooxx ', ' * * ', $STR);








23. What is the result of printing in the 2.php below? Why? Execution Order 1.php->2.php








Cookie,cookie time is a problem. Times () +3600














24. A brief description of PHP commonly used JSON encoding function, how to decode the JSON back to the array








25. When MySQL has '/' in SQL statements, what to do with each specific value of the SQL statement








mysql_real_escape_string








26. How to set header header information in PHP








header (');








27. There are a few scripts below, please 2.php output results








1.php


<?php


setcookie (' Test ', ' cookie_test ', 3600);


?>


2.php


<?php


$cookie = isset ($_cookie[' test '))? $_cookie[' test ': ' COOKIE ';


Echo $cookie;


?>








I am here


1


Summary


A. If an include or include_once is not called in a function or method, the output is the same.


B. If an include or include_once is invoked in a function or method, it is important to note that if you want to have results for the second and subsequent calls, you must use include instead of include_once.








28. Briefly describe the function
of Call_user_func







calls a function or a function inside a class, returning the value of the first argument. Similar functions Call_user_func_array








29. Visit assumed Nginx has been configured server_name www.120.net xxx.120.net


visit after asking http://www.120.net/index.php and http://xxx.120.net/index.php

What are the
$_server["SERVER_NAME"] and $_server["Request_uri"] respectively








www.120.net xxx.120.net


/index.php/index.php








30. The properties of a file under Linux are drwxr-xr-x with numbers to indicate that their permissions are








Directory permission is 755 owner u have read and write modify permissions belong to Group G have read, modify permissions of the group O with reading and modification permissions








31. The 1Mbps theoretical download speed of broadband is how many kbps, calculated by the method








1*1024/8








1m=1024kb


1kb=1024b


1b=8bit








Part II


1. Simple implementation of a single example + Factory design Pattern abstract class example{//The parameterized factory method public static function factory ($type) {if Clude_once ' drivers/'. $type. '. php ') {


$classname = ' driver_ '. $type;


return new $classname;


} else {


throw new Exception (' Driver not found ');


}


}}//Load a MySQL driver$mysql = example::factory (' mysql ');


//Load a SQLite Driver


$sqlite = example::factory (' SQLite ');


definded (' DRIVER ', '/data/wwwroot/www.want.com/core/driver/'); abstract class Example () {Private Function __construct () {} public static function factory ($type) {if include_once (DRIVER. $type. '). php ')) {return Exampleson::singleton ($type);} else {throw new Exception ("Driver are not found!");} }class Exampleson implements example{//Hold An instance of the class private static $instance;//static private classes instance//A private C Onstructor; Prevents direct creation of object private function __construct () {echo ' I am constructed ';}//The Singleton Method pub Lic static function singleton () {if!isset (self:: $instance) {//If no static private class instance is set, create $c = __class__;//Get Class name self:: $instan CE = new $c} return self:: $instance; }//Example method Public Function bark () {echo ' woof! ';}//Prevent users to clone the instance public function __clon E ()//not allowed to be cloned {Trigger_error (' clone is not allowed. ', e_user_error);


}} Keywords:


1 private static member variable


2 __class__ Get the current class name


3 public static method to obtain single case


4 covers the __clone () method





----10 Words: private static amount, public static method--------





2. Examples of several common magic methods, and explain the role? How do I display our custom content when I print an object?





Magic Function





1. __construct ()


is invoked when the object is instantiated,


when __construct and a function with the class name as the function name exist at the same time, __construct is invoked and the other is not invoked.





2. __destruct ()


is invoked when an object or object operation is terminated.





3. __call ()

The
object invokes a method,


If the method exists, it is called directly;

If
does not exist, it will call the __call function.





4. __get ()


read an object's properties,


If the attribute exists, the property value is returned directly;

If
does not exist, the __get function is called.





5. __set ()


set the properties of an object,


If the attribute exists, then directly assigns a value;

If
does not exist, the __set function is called.





6. __tostring ()


is invoked when an object is printed. such as Echo $obj, or print $obj;





7. __clone ()


is invoked when the object is cloned. such as: $t =new Test (); $t 1=clone $t;





8. __sleep ()


serialize before being invoked. If the object is relatively large, want to cut a little bit of the serialization, you can consider this function.





9. __wakeup ()


Unserialize is invoked to do initialization work on some objects.





10. __isset ()


is invoked when it detects whether an object's properties exist. such as: Isset ($c->name).





11. __unset ()


is invoked when unset an object's properties. such as: unset ($c->name).





12. __set_state ()

Called when the
calls Var_export. Use the return value of the __set_state as the return value of the Var_export.





13. __autoload ()


when an object is instantiated, the method is invoked if the corresponding class does not exist.





Magic Constant





1. __line__


returns the current line number in the file.





2. __file__


returns the full path and file name of the file. If used in the include file, the include file name is returned. Since PHP 4.0.2, __file__ always contains an absolute path, and the previous version sometimes contains a relative path.





3. __function__


returns the function name (PHP 4.3.0 new). From PHP 5 This constant returns the name (case-sensitive) of the function when it is defined. This value is always lowercase in PHP 4.





4. __class__


Returns the name of the class (PHP 4.3.0 new). From PHP 5 This constant returns the name of the class when it is defined (case-sensitive). This value is always lowercase in PHP 4.





5. __method__


returns the method name of the class (PHP 5.0.0 new). Returns the name (case-sensitive) of the method when it is defined.





3. Comparison of class static method and instantiation class method and its advantages and disadvantages





4. There is a forum


threads table records topics and headings, and other information


posts table records the content of the subject and the content of the reply


Threads Table Primary key is Tid


posts table primary key is PID and the subject is labeled Tid


the threads and posts a pair of tid through the


now the amount of data posts table reached 100 million, threads table 20 million, about a subject has 5 replies


Please design the table, Posts table and threads table for MySQL





5. Now there is a MySQL main library/Concou, I would like to ask PHP MySQL query how the PHP program in the implementation of master-slave separation? What is the advantage of master-slave separation to configure the master-slave array file, their own seal to several model functions, query loading slave configuration instantiation, the operation of the destruction of data to add master to instantiate the advantages: increased concurrent load capacity, conducive to data maintenance and security, improve usability disadvantage: Data synchronization some delay





6. Brief introduction of Ucenter single sign-on mechanism


so-called single sign-on, nothing more than a number of sites sharing a user center, to achieve synchronous landing, synchronous exit.





in fact, the user will eventually login, just using AJAX (JavaScript uses SRC asynchronous Cross-domain call) the user would not find.





and the use of the P3P header to achieve, different domain names, single sign-on (Ucenter used cookies)





disadvantage is the use of Ajax customer service-side request, if there are more than 10 applications, login speed slowed down.








7. Linux related has a package http://www.120.net/test-1.0.0.tar.gz


A. Download it to/usr/local/src


B. Install its source code into the/usr/local/test directory


c. He relies on the MySQL package, located in the/usr/local/mysql directory


write the download compile installation process





wget-c Http://www.120.net/test-1.0.0.tar.gz/usr/local/srctar zxvf/usr/local/src/test-1.0.0.tar.gzcd/usr/ Local/src/test-1.0.0./configure--prefix=/usr/local/test--exec--prefix=/usr/local/mysqlmake testmake Install





8. Write a function to get the data using the memcache extension of PHP (cache is about to expire timeout lock)


A. After the data timeout to go to MySQL fetch, after getting finished update memcache


b. Go to MySQL to get the data when the lock, let a process to MySQL pull data, others return memcache in the data





Public Function Get_cache ($key) {if ($this->memcahe) {$var = $this->memcahe->get ($this->pre. $key); $valid = $this->memcahe->get ($this->pre. $key. _valid '); if ($var &&! $valid) {$lock = $this->memcahe->get ($this->pre. $key. _lock '); if (! $lock) {$this->memcahe->set ($this->pre. $key. ') _lock ', True, 0, 60); return false; } return $var; return false; }


Public Function Set_cache ($key, $var = null, $expire = 0) {if ($this->memcahe) {$expire = (int) $expire; $expire = ($expire $expire: $this->expire); $this->memcahe->set ($this->pre. $key, $var, 0, $expire +300); $this->memcahe->set ($this->pre. $key. _lock ', False, 0, $expire); $this->memcahe->set ($this->pre. $key. _valid ', True, 0, $expire); return true; return false; }





9. Brief description of the queue, the principle of the stack








can be seen as a one-dimensional array to operate, the queue advanced first out, only columns in the column header, into the column only at the end of the column, the stack is LIFO, into the stack and out of the stack are from the top of the stack








What does a stack work?







The
stack is an abstract data structure whose operating mechanism is LIFO. When you push a new item onto the stack, any item already inside the stack will be pressed to the bottom of the stack. Similarly, moving an entry out of the stack will cause other entries in the stack to move to the top of the stack. Only the topmost entries in the stack are removed from the stack, and the order in which entries leave the stack is the same as the order in which they are pushed. You might as well recall the loading and unloading process of the vending machine.


10. Arrayaccess is defined as follows to implement an array


arrayaccess {


/* Methods * *


Abstract Public boolean offsetexists (string $offset)


Abstract Public Mixed Offsetget (string $offset)


abstract public void Offsetset (string $offset, string $value)


abstract public void Offsetunset (string $offset)


}


Class single implements arrayaccess{private $name; private static $_instance = null; Private function __construct () {} s tatic function Load () {if (null = = self::$_instance) {self::$_instance = new single ();} return self::$_instance;} publi C function SetName ($name) {$this->name = $name;} public Function GetName () {return $this->name;}/** * Implement four methods * Offsetexists (), used to identify whether an element is defined * Offsetget (), to return the value of an element * Offsetset (), to set a new value for an element * Offsetunset (), to delete an element and corresponding value **/ Public Function Offsetset ($offset, $value) {if (Is_null ($offset)) {$this->container[] = $value;} else {$this->co ntainer[$offset] = $value; The Public Function Offsetget ($offset) {return isset ($this->container[$offset])? $this->container[$offset]: null ; The Public Function offsetexists ($offset) {return isset ($this->container[$offset]);} The Public function Offsetunset ($ Offset) {unset ($this->container[$offset]);} $s = single::load (); $s->setname ("Jack") $s ["name"] = "Mike"; Echo $s->getname(); Jackecho $s ["name"]; Mike


11. Suppose the Coreseek installation directory is/usr/local/coreseek


configuration file is/usr/local/coreseek/etc/test.conf


index name is post


A. Create an index


B. Start service


c. Rebuilding the index (ensuring that the search service is still available during the rebuild)





indexer-c/usr/local/coreseek/etc/test.conf--allsearchd-c/usr/local/coreseek/etc/test.conf indexer-c Local/coreseek/etc/test.conf--all--rotate12. Suppose you have a posts post table that Sphinx incremental quasi real time index to the table, describing your scenario


has a simple implementation using the "primary index + Incremental Index" method. Add a Count table in the database that records the last data ID of the indexed table each time the primary index is rebuilt, so that only the data after this ID will be indexed in the incremental index, and the table will be updated each time the primary index is rebuilt.








13. PHP Code:


$i = $a = ($i + +) + (+ + $i) + $i; $b = (--$i) + ($i-) + $i + 6;





echo "$i, $a, $b"; What is the output





97, 295, 299


97


97+99+99


98+98+97+6








14. The following code is used to obtain client Ip:if (getenv (' http_client_ip ') && strcasecmp (getenv (' http_client_ip '), ' unknown ')) {$ Onlineip = getenv (' http_client_ip ');} ElseIf (getenv (' http_x_forwarded_for ') && strcasecmp (getenv (' http_x_forwarded_for '), ' unknown ') {$onlineip = getenv (' http_x_forwarded_for ');} ElseIf (getenv (' remote_addr ') && strcasecmp (getenv (' remote_addr '), ' unknown ')) {$onlineip = getenv (' Remote_ ADDR ');} ElseIf (Isset ($_server[' remote_addr ']) && $_server[' remote_addr '] && strcasecmp ($_server[' Remote_ ADDR '], ' unknown ') {$onlineip = $_server[' remote_addr '];} But with HTTP_ start of the request header is the client can forge information, in the reverse proxy environment, how to ensure that PHP will not receive forged HTTP_CLIENT_IP, http_x_forwarded_for value?














15. For example, Google,baidu and other large web sites, when the use of different clients (such as mobile phone and PC) access to the same URL, the rendering of the page is not the same, this is what principle? If you can give a practical solution, you can add points.














simple can be judged by user_agent, but its preliminary





can use the server or mobile phone terminal features or WAP gateway accept information, etc.

















16. MAGIC_QUOTES_GPC and Magic_quotes_runtime values in production environment php.ini should be set why? Onoff17. PHP can use file_get_contents when invoking a remote HTTP interface, but when the remote host is unreachable or the response is slow, the local PHP process is suspended for a long time, which affects the stability of the local server, and how to avoid timeouts when the PHP process is suspended for a long time?














File_get_contents can set the next timeout time $ctx = stream_context_create (Array (' HTTP ' => array (' timeout ' => 1


)


)


);


file_get_contents ("http://www.want.com/", 0, $ctx);


Curl Implementation to obtain the remote HTTP interface can also be set time-out time curl_setopt ($s, curlopt_timeout, $timeout);


18. How do I prevent DNS queries from slowing down to timeout? MySQL Character set names * command What are the values of the system variables? (ACE) A, character_set_client B, Character_set_system C, Character_set_results D, Character_set_server E, Character_set_ Connection F, Character_set_database20. Which of the following collation rules are not case-sensitive? (a) A, utf8_general_ci B, Utf8_general_cs C, Utf8_general_bin21. How to eliminate XSS attacks?


strip_tags can be initially filtered, or write their own filter functions for special tags for processing, with the ASCII code to replace 23. How to prevent CSRF attack?


In the Web application side defense csrf vulnerabilities, generally using Referer, token or authentication code, TOKENF way or more trustworthy

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.