1, PHP switch is very special, support strings and other basic classes to get.
function Dump_array ($var) {switch (GetType ($var)) {case ' integer ': Case ' double ': Case ' string ': Echo $var; Break;case ' Array ': Echo ' <table border= ' 1 ' > ';d o{echo ' <tr><td align= ' left ' valign= ' top ' > '; echo key ($var); Echo ' </td><td> ';d ump_array ($var [Key ($var)]; Echo ' </td></tr> ';} while (Next ($var)), Echo ' </table> '; Break;default:echo ' unknow data type. '; Break;}}
2. Object-oriented
2.1 PHP support for objects is not complete, such as the inability to fully use polymorphism to execute a function in a overridden parent class.
2.2 PHP cannot have two references to the same object, and when a reference is assigned to the second variable, a copy of the image is copied, and the new reference points to the replica.
3, URL parameters should use the Rawurlcode () function to convert the encoding, otherwise prone to illegal values and cause a crash
With Rawurlcode encoding, the decoding process is automatic when it is received.
4, PHP and HTML mixed
in PHP, adding @ before a function call can force the output of the corresponding warning and error message.
The following is a mixed MySQL database connection page.
<?phprequire (' common.inc '); require (' Post_get_arr.inc ')? ><?phpif (Empty ($arr _request[' username '])) {$ Username = ' root0 ';} else{$username = $arr _request[' username ');} if (Empty ($arr _request[' password ')) {$password = ' 123456 ';} else{$password = $arr _request[' password ');} $id _link = @mysqli_connect (' localhost ', $username, $password), if (! $id _link) {affy_message ("the connection to the local D Atabase has failed. Pleaseenter a username and password so a connection can be made. "); ><!--Display A form to gather username and password info--><form action= "connect_db.php" method= "POST" >&L T;table><tr><td>username</td><td><input type= "text" name= "Username" value= "root" ></td></tr><tr><td>password</td><td><input type= "Password" Name= " Password "></TD></TR><TR><TD colspan=" 2 "><input type=" Submit "value=" Connect to Database "></td></tr></table></form><?phP exit; }?><p> the Connect was successful!</p>
5. The code can be called at the top of the PHP call, and the Get and post parameters are uniformly placed in the array
<?php//post and get value$arr_request = Array (); $HTTP _get_vars = $_get; $HTTP _post_vars = $_post;if (count ($HTTP _get_ VARS) {(List ($key, $value) = each ($HTTP _get_vars)) {$arr _request[strtolower ($key)] = $value;}} if (count ($HTTP _post_vars)) {while (list ($key, $value) = each ($HTTP _post_vars)) {$arr _request[strtolower ($key)] = $ value;}}? >
PHP Learning Notes (ii)