PHP is less practical than Tips. 1. simply determine the validity of an IP address. email regular expression judgment 3. example 4: Check whether the IP address and mask are valid. about form refresh 5. about form refresh 1. simply determine IP address legality if (! Str 1. check IP address validity
2. email regular expression judgment
3. check whether the IP address and mask are valid.
4. about form refresh
5. about form refresh
1. simple determination of IP address legality
If (! Strcmp (long2ip (sprintf ("% u", ip2long ($ ip), $ ip) echo "is ipn ";
----
2. email regular expression judgment
Eregi ("^ [_. 0-9a-zA-Z-] + @ ([0-9a-zA-Z] [0-9a-zA-Z _-] +.) + [a-zA-Z] $", $ email );
----
3. check whether the IP address and mask are valid.
$ Ip = '1970. 168.0.84 ';
$ Mask = '2017. 255.255.0 ';
$ Network = '1970. 100 ';
$ Ip = ip2long ($ ip );
$ Mask = ip2long ($ mask );
$ Network = ip2long ($ network );
If ($ ip & $ mask) = $ network) echo "valid ip and maskn ";
?>
----
4. today we have solved a very depressing problem.
The Add user page of ipb is toadduser. php seems to submit the statement repeatedly, so when a new user is added, it always reports that the user already exists... I have been depressed for three days, and I finally got it done. it's amazing!
----
5. about form refresh
Q: Why are all fields cleared after I click the back button of the browser?
A: This is because you have used the session_start function on your form submission page. This function forces the current page not to be cached. The solution is to add the header ("Cache-control: private") after your Session_start function. Note that your PHP program cannot have any output before this line.
Supplement: There is also a session-based solution, which is added before session_start.
Session_cache_limiter ('nocache'); // clear the form
Session_cache_limiter ('private'); // do not clear the form, only during the effective period of the session
Session_cache_limiter ('public'); // do not clear the form, as if the session is not used
You can add session_cache_limiter ("private, max-age = 10800") before session_start ");
From phpe.net
----
6. get the output of the file download header quickly
Header ("Content-type: application/x-download ");
Header ("Content-Disposition: attachment; filename = $ file_download_name ;");
Header ("Accept-Ranges: bytes ");
Header ("Content-Length: $ download_size ");
Echo 'XXX'
...... 11:50:30
----
7. use the header to output the ftp download method and support resumable data transfer.
Example:
Header ('pragma: public ');
Header ('cache-Control: private ');
Header ('cache-Control: no-Cache, must-revalidate ');
Header ('Accept-Ranges: bytes ');
Example 2. check whether the IP address and mask are valid. 4. refresh the form. 5. refresh the form. 1. simply judge the validity of the IP address. if (! Str...