Features Flashcards
Where are uploaded files stored by default?
In the server’s default temporary directory.
How can you upload multiple files with PHP?
Use a different name for input.
Does PHP support PUT requests?
Yes. First you would configure Apache to handle PUT requests with a specific PHP script,
What does allow_furl_open do?
It allows you to use HTTP and FTP urls with most of the functions that take a filename as a parameter.
Can you use PHP to write to files on an FTP server?
Yes, but if you try to overwrite a file that already exists, the fopen() call will fail.
What are the 4 possible states of a connection status in PHP?
0 - NORMAL
1 - ABORTED
2 - TIMEOUT
3 - ABORTED AND TIMEOUT
What does register_shutdown_function() do?
It registers a function to be executed on shutdown.
How can you trigger something to happen if a client aborts a connection?
Check if the client disconnected with connection_aborted().
How can you determine the connection status?
Call connection_status().
What are persistent database connections?
Links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there’s already an identical persistent connection (that remained open from earlier) - and if it exists, it uses it. If it does not exist, it creates the link. An ‘identical’ connection is a connection that was opened to the same host, with the same username and the same password (where applicable).
When are persistent database connections particularly helpful?
When connection overhead is high.
What are a couple of caveats to keep in mind when using persistent connections?
- When using table locking on a persistent connection, if the script for whatever reason cannot release the lock, then subsequent scripts using the same connection will block indefinitely and may require that you either restart the httpd server or the database server.
- When using transactions, a transaction block will also carry over to the next script which uses that connection if script execution ends before the transaction block does.
In either case, you can use register_shutdown_function() to register a simple cleanup function to unlock your tables or roll back your transactions. Better yet, avoid the problem entirely by not using persistent connections in scripts which use table locks or transactions (you can still use them elsewhere).