Php returns the function formatting variable of the file extension, such as php redirection webpage. 1. returns the file extension.
Function getformat ($ file)
{
$ Ext = strrchr ($ file ,".");
$ Format = strtolower ($ ext );
Return $ format;
}
2. format the variable
$ Num = 1;
Printf ("% 04d", $ num );
?>
3. php redirection webpage
// For example, redirect to www.cgsir.com (note that html content is not included before redirection)
Header ("location: http://www.jb51.net ");
Or
Echo" ";
4. restrict the size of uploaded files
// $ Limit_size indicates the maximum file size.
$ Limit_size = 50000;
$ File_size = $ HTTP_POST_FILES ['ufile'] ['size'];
If ($ file_size> = $ limit_size ){
Echo "the size of your file exceeds the limit.
";
Echo "your file size is =". $ file_size;
Echo "K ";
Echo"
The file size is limited to = 50000 k ";
}
Else {
// The directory to which the object is uploaded, that is, copying the object from the temporary directory to the target directory.
If (copy ($ HTTP_POST_FILES ['ufile'] ['tmp _ name'], $ path ))
{
Echo "uploaded successfully
";
Echo "";
}
5. common php algorithm for string encryption:
5.1 $ db_password = md5 ($ random_password );
5.2 $ db_password = sh1 ($ random_password );
6. log out
// Log out
Session_start ();
Include_once ('Des/header. php ');
If (isset ($ _ SESSION ['User _ id'])
{
Unset ($ _ SESSION ['User _ id']);
Session_destroy ();
Echo'
';
Echo 'exited successfully!
';
Echo'
Redirecting... please wait ......
';
Echo'