PHP php.ini Directives Tutorials

php.ini is an important file which declares default settings for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits.

Change maximum upload file size

By default, the maximum upload file size for PHP scripts is set to 2 MB and the maximum file size allowed posted via a form is 8MB.

upload_max_filesize = 10M
post_max_size = 11M

Remember to use bigger value for post_max_size compared to upload_max_filesize to ensure uploading to work properly.

Increase Memory Limit

When working with PHP, developers often encounter this error message “Fatal error: Allowed memory size of x bytes exhausted (tried to allocate x bytes) in /path/to/php/script”.

It happens because the system runs out of allocated memory to PHP when executing a script. Increasing memory limit to a bigger number to address this issue.

memory_limit = 256M

Enable Sockets Extension

Socket extension is not enabled by default even thought it is packed with PHP when installed. You can check to see if it was missing by finding for php_sockets.dll in php\ext folder.

Un-comment or add the following line to enable the extension:

extension=php_sockets.dll

Leave a Comment

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close