3.12php. This is my first blog to commemorate the first problem I saw. when the picture exceeds 1 MB, the following error may occur. of course, this is also true for php. ini settings. this is my first blog to commemorate it. I read it myself.
First error
When the image size exceeds 1 MB, the following error may occur. of course, this is also related to your php. ini settings. if memory_limit 16 MB is too small in your php settings, the following error will occur!
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 3456 bytes) in
Solution
Ini_set ("memory_limit", "60 M ");
Dynamically set the size before imagecreatefromjpeg to solve the problem of insufficient memory.
Some servers may limit the use of ini_set () for this function, so that no error is reported or Thumbnails cannot be generated.
Therefore, you only need to contact the server to manually modify php. ini.
Problem 2 get file name
Basename
Basename -- returns the file name part of the path.
$ Path = "/home/httpd/html/index. php ";
$ File = basename ($ path); // $ file is set to "index. php"
$ File = basename ($ path, ". php"); // $ file is set to "index"
?>
Third problem: execute and output
Print "a total of five files to be processed ";
Sleep (1 );
Print str_pad ("", 100000 );
Flush ();
For ($ I = 1; $ I <= 5; $ I ++)
{
Sleep (1 );
Print "# $ I finished ";
Print str_pad ("", 10000 );
Flush ();
}
Print "Congratulations, all processing is successful! ";
Fourth problem: mysql_pconnect ()
The mysql_pconnect () function opens a persistent connection to the MySQL server.
Mysql_pconnect () and mysql_connect () are very similar, but there are two main differences:
When connecting, this function will first try to find a (persistent) connection that has been opened with the same user name and password on the same host. if it is found, the connection id is returned without a new connection.
Second, after the script is executed, the connection to the SQL Server will not be closed. this connection will be enabled for future use (mysql_close () will not close the connection established by mysql_pconnect)
However, using Pconnect often causes Mysql connection failure and prompts too many connections because Apache does not automatically close mysql connections after pconnect.
My understanding: As for the time when mysql_pconnect is closed, I think it will be closed only when the database is closed ....
Mysql_connect () is not closed after the program is executed, because I joined the first execution program and connected it with mysql_connect. the second time I dropped the connection, I can still query it. It means that mysql_connect () is not switched off after the program is executed, but a holding time. This is called mysql connection duration.
As for mysql_pconnect, the connection is continuously maintained, and there is no limit on the length of time until the database closes the connection. Mysql_pconnect first checks whether a connection is available for each connection. The original statement is as follows: when connecting, this function will first try to find a (persistent) connection that has been opened with the same user name and password on the same host. if it is found, the connection id is returned without a new connection.
Will mysql_connect search for available connections during connection? Find the relevant php Manual. Original statement: if the same parameter is used to call mysql_connect () for the second time, a new connection will not be established, but an opened Connection ID will be returned.
The first problem is displayed by yourself. when the image size exceeds 1 MB, the following error may occur. of course, this error is related to php. ini settings...