- $tmp = 0 = = "a"? 1:2;
- Echo $tmp;
- ?>
Copy CodeResult of 1 int and string 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"; 1109063 is assigned to $uid in a line of code, Milo is assigned to $user, and 1 is assigned to $type space as list ($uid, $user, $type) = E Xplode ("", $str); \ t below 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. The following types of signed and unsigned ranges are listed TINYINT SMALLINT mediumint inttinyint-2^7-2^7-10 ~ 2^8-1smallint-2^15-2^15-1 0 ~ 2^16-1mediumint -2^23-2^23-1 0 ~ 2^24-1int-2^31-2^31-1 0 ~ 2^32-1 6. Assemble the following array in one line into a string I am milo! Day up!
- $arr = Array (
- ' I ', ' AM ', ' milo! ', ' Day ', ' Day ', ' up! '
- );
- ?>
- $str = Strtolower (Implode ("", $arr));
Copy Code7. Call the following function to get the function and get the value of Count
- function get_list ($cnd = Array (), & $count = False)
- {
- Pseudo-code handles $CND and assigns values Datas
- $datas = ' I am call back ';
- $count && $count = rand (1, 10000);
- return $datas;
- }
- ?>
- $count = 1;
- $data = get_list ($cnd,& $count);
- Echo $count;
Copy Code8. Several ways to replace the session mechanism, simple description of their merits MySQL, memcache, cookies maintain a unique status identification code 9. Possible causes of the following HTTP status codes, how to handle 200, 301, 404, 502, 503200 requests have been successful, the requested response header or data body will be returned with this response. 301 the requested resource has been permanently moved to a new location, and any future references to this resource should use one of several URIs returned by this response. If possible, clients that have link editing capabilities should automatically modify the requested address to the address returned from the server. Unless otherwise specified, the response is cacheable. The new permanent URI should be returned in the location domain of the response. Unless this is a HEAD request, the response entity should contain a hyperlink to the new URI and a short description. If this is not a GET or HEAD request, the browser disables automatic redirection unless the user confirms it, because the requested condition may vary. Note: For some browsers that use the http/1.0 protocol, when they send a POST request that gets a 301 response, the next redirect request becomes a Get method. 404 the request failed and the requested resource was not found on the server. No information can tell the user whether the situation is temporary or permanent. If the server knows the situation, it should use the 410 status code to tell the old resources because of some internal configuration mechanism problems, has been permanently unavailable, and there is no jump to the address. 404 This status code is widely used when the server does not want to reveal exactly why the request was rejected or if no other appropriate response is available. 502 An invalid response was received from the upstream server when a request was attempted by a server that is a gateway or agent working. 503 The server is currently unable to process requests due to temporary server maintenance or overloading. This situation is temporary and will be resumed after a certain period of time. If the delay time can be estimated, then the response can include a retry-after header to indicate the delay time. If this retry-after message is not given, the client should handle it in a manner 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 connections to clients. All OK, the answer document for Get and post requests is followed. 301 Moved Permanently The document requested by the customer elsewhere, the new URL is given in the location header, and the browser should automatically access the new URL404 not Found unable to find the resource at the specified position. This is also a common answer. 502 Bad Gateway server as a gateway or proxy, the server returned an illegal reply in order to complete the request to access the next server. 503 Service Unavailable Server failed to answer due to maintenance or heavy load. For example, a servlet might return 503 if the database connection pool is full. A retry-after header can be supplied when the server returns 503. 10. Have the following database, use the original ecological MySQL extension to connect and query the first 10 rows of the user table Host:192.168.0.254port:3306user:onepass:piecedatabase:db_usertable: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))
- {}
Copy Code11. Use AutoLoad ($class) to implement automatic loading of classes in the Lib directory and to 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 ');
- -----------------------------------------------------------
Copy Code12. Use Set_error_handle to catch errors and output, level yourself
-
-
-
Set_error_handle (callback,level)
- function callback (int $errno, string $e Rrstr [, String $errfile [, int $errline [, array $errcontext]]) {
- }
-
Function Dealerrorhan Dler ($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);
-
Copy Code13. Briefly describe two methods of notice warning to block PHP programs initialize variables, file start setting error level or modify php.ini settings Error_reportingset_error_handler and @ suppress errors 1. Add: Error_reporting (E_all & ~e_notice); 2. or modify in php.ini: Error_reporting = E_all instead: error_reporting = E_all & ~e_notice3.error_reporting (0); or modify Php.inidisplay_errors=off 1 2 3 4 Next last |