php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64299 Global variables not visible when using CLI
Submitted: 2013-02-25 21:50 UTC Modified: 2013-02-28 16:14 UTC
From: andrew dot mof at gmail dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.4.12 OS: Ubuntu 12.10
Private report: No CVE-ID: None
 [2013-02-25 21:50 UTC] andrew dot mof at gmail dot com
Description:
------------
99% sure this is a bug. This code works fine when apache runs it but when I run it though CLI it doesnt see the variable.

That said, this work:

$GLOBALS['jobID'] = 123;

Test script:
---------------
#!/usr/bin/php
<?php

// In my script this function is included in a seperate file
function addLine() {
   global $jobID;
   echo $jobID;
}

$jobID = 123;

addLine();


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-26 04:16 UTC] pajoye@php.net
-Status: Open +Status: Not a bug
 [2013-02-26 04:16 UTC] pajoye@php.net
In PHP 4.2.0, the 'register_globals' setting default changed to
'off'. See http://www.php.net/release_4_2_0.php for more info.
We are sorry about the inconvenience, but this change was a necessary
part of our efforts to make PHP scripting more secure and portable.

There is no bug here. Works just fine.
 [2013-02-28 16:05 UTC] anon at anon dot anon
@pajoye: register_globals has nothing to do with this; what are you saying?

That said, the test script appears to work perfectly. How could it not?
 [2013-02-28 16:14 UTC] andrew dot mof at gmail dot com
All I can say is that the function cannot see the variable in CLI but can do when its run by apache, which is why it confused me so much. My functions are being included in a seperate file, does this affect the global scope in CLI?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 02:01:29 2024 UTC