1

I am running apache2 on Ubuntu 14.04 LTS with 5.5.9-1ubuntu4.

I was uploading a working code to the server but got "NetworkError: 500 Internal Server Error"

So I started tracking down the problem. I traced it back and found out it seems to be a problem with namespace declaration. In trying to figure it out (simplify things) I created a new file that duplicates the error.

<?php
    namespace MyProject ;

    echo '"', __NAMESPACE__, '"'; // outputs "MyProject"
?>

When put through a browser it generates the above error.

If I comment out the 2nd line, it runs without error and produces the expected output

""

Any ideas what is happening?

1
  • What does your error log say? "500" is just Apache's reaction to PHP failing, PHP itself will have a more detailed error in its logs.
    – deceze
    Apr 24, 2014 at 19:24

1 Answer 1

1

There is just a semilicon ; missing on the second line:

<?php
   namespace MyProject ;

   echo '"', __NAMESPACE__, '"'; // outputs "MyProject"
?>

You should also get rid of the spaces and blank lines before your <?php opening tag.

7
  • Sorry the problem exists with the ";". It was missing due to a typo... I have edited the original question.
    – farley
    Apr 24, 2014 at 18:10
  • @farley: Have you got anything else on this page? Copy and paste page code here
    – potashin
    Apr 24, 2014 at 18:17
  • @Notulyssues - In order to track this down and make sure there was nothing else I have nothing else on the page. The code above now exactly matches the code I am running through my browser. Comment out the namespace line and I get output. Leave it uncommented and I get the 500 Error. Seems PHP is not parsing the 'namespace' declaration.
    – farley
    Apr 24, 2014 at 18:22
  • @Notulyssues - paste just picked up on the pastbin
    – farley
    Apr 24, 2014 at 18:26
  • @farley : I don't know, it works fine on my machine. I can't suggest anything more than just check any spaces before <?php tag .One more thing : Are there any errors in your php log?
    – potashin
    Apr 24, 2014 at 18:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.