php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20224 Constants / Global variables non printable
Submitted: 2002-11-02 20:12 UTC Modified: 2002-11-02 21:30 UTC
From: phresno at concept-factory dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.2.2 OS: Slackware Linux Kernel 2.4.5
Private report: No CVE-ID: None
 [2002-11-02 20:12 UTC] phresno at concept-factory dot com
I'm not sure if this is a problem with constants and pre-registered globals, or the printing mechanism.

When setting up a constant such as this:
define("SELF", $SCRIPT_NAME);

and then printing with any of the following:
echo SELF;
print(SELF);
pritnf("%s", SELF);

The output is nothing, however, if I do this:
printf("%s", SELF . "?foo=bar");

it will print properly.

I believe it's a problem with the globals, as when I try just to print $SCRIPT_NAME or $SCRIPT_FILENAME I go no output unless I concat'ed it to something else such as shown above.

My PHP configuration is as such:
'./configure' '--with-apxs=/usr/sbin/apxs' '--disable-short-tags' '--enable-bcmath' '--with-zlib-dir=/usr/lib' '--enable-ftp' '--with-gd=/usr/local/gd-1.8.4' '--enable-gd-native-ttf' '--with-jpeg-dir=/usr/lib' '--with-png-dir=/usr/lib' '--enable-sockets' '--without-mysql' '--with-pgsql=/usr/local/pgsql'

On Slackware (8.0) Linux, Kernel 2.4.5, Apache 1.3.20. For this particular script, I was working with sessions, and DID use the following lines to disable some sessions settings:
ini_set("session.use_cookies", 0);
ini_set("session.use_trans_sid", 0);

The script was written prior to 4.2.2 and the auto enabled trans_sid was creating extra data in my GET's that I had already accounted for in my own script.

-Richard

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-02 21:30 UTC] wez@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.
 [2002-11-03 12:39 UTC] phresno at concept-factory dot com
Even with register_globals off, why does it sometimes print, and sometimes not? If it's not registering the global it should never print the contents of the global.

Thus both:
printf("%s", $SCRIPT_NAME);
and
printf("%s", $SCRIPT_NAME . "?foo=bar");

Should never print the contents of $SCRIPT_NAME, however, in the second instance, it prints the contents of $SCRIPT_NAME, even with register_globals off.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu May 19 06:05:44 2022 UTC