-2
$reset_Array=(); // I forgot to put the keyword "array"

Correct way should be

$rest_Array= array(); 

Why does Apache crash when I try to execute wrong code.

What is happening internally?

2
  • 1
    Which version of PHP are you using (5.2.x?) and on which platform (Linux? Windows?)? Commented Sep 4, 2012 at 6:39
  • 1
    I find it hard to believe that Apache crashes. Most likely, PHP aborts execution due to an error. You should be getting 500 Internal server error. Commented Sep 4, 2012 at 6:45

2 Answers 2

2

I don't think that Apache crashes. What happens is your PHP execution aborts, resulting in you seeing 500 Internal server error. This is due to the fact that syntax

$reset_Array=();

is invalid in PHP. PHP is trying to parse this line and encounters an error. It returns this error and the execution aborts. Try the following: put in a new file test.php the following:

<?php

$reset_Array=();

?>

And execute this with a command-line interpreter with -l parameter (lint - syntax checking):

$ php -l test.php

You will get the following error:

$ php -l publish/test.php 
PHP Parse error:  parse error in test.php on line 3
Errors parsing test.php

Once PHP encounters this error, it cannot continue executing the script, because it cannot parse it. Hence you receive an error when you try executing it under Apache.

P.S. The above commands are shown from unix/linux shell. If you are running under windows, then your prompt may be something like C:\Documents > instead of $.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the input. On thorough study of the code i found it was something else that was resulting in crash. And yes "error_reporting" helped me in the debugging the actual issue.
1

Apache isn't crashing. It's just no errors are being displayed.

You could look at the errors in the error_log file, which resides in the same directory as your php script.

What you could do is look in your php.ini file for the uncommented line error_reporting = foo. Change that foo to E_ALL.

Then it should show the errors, instead of just simply so-called 'crashing'.

1 Comment

Note that this doesn't display parsing errors - I needs to fully parse the file before beginning to execute the script. Since it's a parse error, it never gets as far as execution. See here. To enable parsing errors being displayed, you need to do it in your ini file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.