php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49713 global vs static usage
Submitted: 2009-09-29 16:34 UTC Modified: 2009-10-01 16:16 UTC
From: patrickdk at patrickdk dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.11 OS: Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: patrickdk at patrickdk dot com
New email:
PHP Version: OS:

 

 [2009-09-29 16:34 UTC] patrickdk at patrickdk dot com
Description:
------------
the global modifier causes http 500 errors but doesn't produce any syntax errors or other messages when used incorrectly. It's behavure isn't documented and is described next to static that works differently.

Reproduce code:
---------------
<?php global $test=true;


Expected result:
----------------
It should give a syntax error, and manual should be updates to explain assigning a value on the global declaration isn't valid, unlike with static.


Actual result:
--------------
php-cgi test.php 

Status: 500 Internal Server Error
X-Powered-By: PHP/5.2.11
Content-type: text/html



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-30 18:32 UTC] sjoerd@php.net
Thank you for your bug report.

Does this problem occur with all parse problems or just this one? Do you have error reporting enabled? Is there something in your PHP error log?
 [2009-10-01 04:09 UTC] patrickdk at patrickdk dot com
I dunno what you mean by 'all parse problems'.

I turned on as much debugging info as I can, have all warnings/notify also logged. I saw normal errors like syntax/unused vars/... in the logs, but never anything about that global line.

I used the test code:
<?php global $test=true;

To figure out what was wrong. I also used this to see if it made a difference:
<?php function testing() { global $test=true; }

And it didn't, both fail without any warning/error/message.
 [2009-10-01 12:52 UTC] patrickdk at patrickdk dot com
did some more testing, dunno.
It seems to only be that one machine though that doesn't print the syntax warning, even though warnings/errors are getting logged.

Would still be good to make this clear in the php manual though.
 [2009-10-01 16:16 UTC] jani@php.net
Check your php.ini settings, any possible .htaccess / httpd.conf 
settings, etc. This is no bug, I get proper errors with properly 
configured server.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 27 01:00:02 2025 UTC