PHP Internal Server error has no detail anywhere in the server

Hi folks,
i am fedup. i spent hours to get the errors to display in the server. no lunck. i am on a shared hosting space. below script only shows internal server error when run. but no extra info shown in either chrome > inspect nor in error_log in the file manager in same folder. i need to trouble shoot a large script. but its painfull without error detail.


ini_set('display_errors', 'true');
ini_set("display_errors", "1"); // shows all errors
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");

echo "hi;


in above simple script, it has a missing double quote. but it only shows internal server error. where can find the error detail stating about the missing quote ?

a search for php-error.log which suppose to be created in above script either does not show any such file in cpanel file manager.

There is a missing clsoing doule quote after Hl

Try this:

declare(strict_types=1);    // fail fast

ini_set('display_errors', '1'); // shows all errors
ini_set('log_errors', '1');

$errorLog = './php-error.log';
ini_set('error_log', $errorLog);

// SAVE error message
error_log( "\n\nLine: " .__line__  .' ==> ' .date('H:i:s'), 3, $errorLog );

echo '<hr>';
  echo '<h4>file: $errorLog : ' .$errorLog .'</h4>';
  echo '<pre>' .print_r( file_get_contents($errorLog), TRUE) .'</pre>';
echo '<hr>';

echo "hi";

The php error_log varies tremendously depending on the platform (Widnows, Linux, Mac, etc).

Try Googling for “PHP error_log location <your-platform>

Parse errors are quite difficult to throw error messages for. PHP can’t easily tell whether your typo there is to not close the quotes on the end of your echo statement, or that you intended to include the closing-PHP tag in your display (because perhaps your site is showing how to program PHP), and in that case the error is that you have no closing-PHP tag.

Once you have multiple levels of opening and closing curly-braces and program logic, it’ll get worse, so it’s a good idea to get into good habits, and use an editor that supports syntax-colouring to help you out. You can see in your original post that the code display leaves the closing tag in red, when it should really be black at that point, and a decent editor (I use Notepad++) would do similar. They’re not perfect, but they help.

That will try to write to the /tmp folder at the root, so if it’s shared hosting you may not have access to that folder. Try “…/php-error.log” instead and see if the file is written in your home folder.

If not, I’d suggest asking your hosting company. The error should be written to a log somewhere but it’s difficult to say where.

My Post #2 writes to the same development folder :slight_smile:

$errorLog = './php-error.log';
ini_set('error_log', $errorLog);
1 Like

Also, linting all your files to detect errors like that helps. Run php -l file.php.

Hi guys, sorry for late reply. ill read your responses and reply you in a moment.

Hi john,

just tested your suggession (shown below) with still keeping the internal server error

$errorLog = './php-error.log';
ini_set('error_log', $errorLog);

but this files is not created. i even did a search for this file in file manager with search all files option. its not found. that mean this file php-error.log not created after the error.

sorry, you mean where to run that?

Hi guys,
a search in file manager for ‘error’ had brought me the error log file. now i see the php errors here :


that mean the file is located outside of public_html folder. which is very unusual.

Not really - why would you want your site error information exposed to the public?

i have no idea how it came to that location. may be a server configuration?

The error log’s location is defined by the server setup, yes.

I think you do not have your PHP environment set for maximum error reporting otherwise there would have been an error or warning about the php_error.log not being created.

Try manually creating the file or the following:

ini_set('display_errors', '1');

$errorLog = './php-errors.log';

echo '<br>';
echo '<br>path: ' .getcwd();
error_log("MESSAGE \n", 3, $errorLog);
error_log("MESSAGE \n", 3, $errorLog);
error_log("MESSAGE \n", 3, $errorLog);
echo '<pre>';
  echo file_get_contents($errorLog);
echo '</pre>';

Check the Free Online PHP Manual, there are lots of other options:

On a command line

Also note that setting ini-values can be disabled by the server owner. cf.

1 Like

I had heard rumours about giving and did not think it was so easy :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.