≡ Menu

PHP

Return 503 when server is under maintenance

When your server is under maintenance like you are upgrading your WordPress install or you are moving some pages around, it is imperative that you return the correct HTTP status code when the maintenance is going on. The correct HTTP status code to return is 503. If you return a 404 page not found, search [...]

{ 0 comments }

phpMyAdmin: mbstring PHP extension not found error

Question - When I open phpMyAdmin, I get the following error: The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results. How do I fix this? The solution is to install [...]

{ 0 comments }

How to log all PHP errors to a file?

The question - I want to log all PHP errors to a log file. Is there a PHP directive or statement that can achieve this? PHP has a way to log all errors to a log file using the error_log directive. This directive can be set in your php.ini file: First locate your php.ini: [root@server [...]

{ 0 comments }

How to control display of error messages in PHP?

The question - I want to disable all error reporting in my PHP script. I don't want PHP to report any errors to the end user on his browser. Is there a PHP command or directive that can be used to do this? PHP has a built in function called error_reporting which can be used [...]

{ 0 comments }

Getting 500 Internal Server Error on PHP pages

The question - When I try to visit my PHP pages using a browser, I get a 500 internal server error. What could be the problem? A 500 internal server error can be caused by several reasons, some of which I describe below. The error means that something went wrong with the web server which [...]

{ 0 comments }

How to increase PHP max_execution_time?

Question - I have a PHP script that runs for about 15 minutes. It processes a lot of data and outputs a summary. But after a few seconds, PHP says that max_execution_time was exceeded and it aborts the script. How do I increase the max_execution_time so that my script would complete its processing? The PHP [...]

{ 0 comments }

PHP – Increase maximum upload file size limit

The question - I have a script that allows users to upload files to the server. Sometimes, when the file is large (40 megabytes), it errors out saying that the file is too big for uploading. I need to increase the upload file size limit. How do I do that? Is there an Apache or [...]

{ 0 comments }

How to find out my PHP and Perl versions?

Question - I am using CentOS Linux as my web hosting server. How do I find out the versions of the Perl and PHP interpreters on my machine? Perl and PHP both are interpreted languages. Perl stands for Practical Extraction and report language. PHP stands for PHP Hypertext Processor. The acronym of PHP is called [...]

{ 0 comments }

How to parse HTML using PHP?

The question - I need a way to parse HTML using PHP. Is there a library available that can help me do this? There is a package available for PHP called PHP Simple HTML DOM which can be used to do this. In this tutorial, I will explain in detail with examples on how to [...]

{ 0 comments }

How to check and increase the PHP memory limit?

The question - I need to check what is the memory limit that is set for my PHP scripts. I also get an error saying allowed memory limit of nnnn bytes exhausted. How do I check and increase the PHP memory limit? There are several ways in which you can check your PHP memory limit. [...]

{ 0 comments }