ID:               14645
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Open
-Bug Type:         Variables related
+Bug Type:         Documentation problem
 Operating System: Linux
 PHP Version:      4.1.0
 New Comment:

In another report Markus said this was a documentation
problem..reclassified.



Previous Comments:
------------------------------------------------------------------------

[2001-12-21 10:38:37] [EMAIL PROTECTED]

Hi PHP-Developer-Community,

here are
- a description of the bug,
- a short test-script and
- the configuration I used:

A global variable within a function is assigned something by reference
. This value is only visible within this function - not in the main
script, not in functions calls by this function.

The same assignment by value works fine.

This sounds buggy, but it's getting worse! Things get really confusing
if you remove the comment before "#set_by_reference_GLOBALS();".

This function accesses the global variable over the $GLOBALS array.
This assignment works, BUT: After this function is called, the other
function I mentioned before that assigns by value does not work anymore
for the rest of the script-session! (It only works if this line is
commented out)!!!

=================[test.php]=================
<PRE><?
$global = "hello world";

function show($prefix)
{
        global $var;
        echo "$prefix: $var\r\n";
}

function set_by_reference()
{
        global $var, $global;
        $var = "[empty]";
        $var =& $global;
        show("var assigned by reference");
}

function set_by_value()
{
        global $var, $global;
        $var = "[empty]";
        $var = $global;
        show("var assigned by value");
}

function set_by_reference_GLOBALS()
{
        global $var, $global;
        $var = "[empty]";
        $GLOBALS["var"] =& $global;
        show("GLOBALS[var] assigned by reference");
}

#set_by_reference_GLOBALS();
set_by_reference();
set_by_value();

?></PRE>
=================[test.php]=================

==============[SYSTEM CONFIG]===============
System: Linux 2.4.16-SMP
Apache: 1.3.22
PHP: 4.1.0
Configure Params:
./configure
  --prefix=/usr/local/php
  --with-mysql=/usr
  --with-apache=/usr/src/packages/SOURCES/apache_1.3.22
  --with-sybase-ct=/usr/local/freetds
==============[SYSTEM CONFIG]===============

=================[php.ini]==================
[PHP]
engine = On
short_open_tag = On
asp_tags = Off
precision    =  14
y2k_compliance = Off
output_buffering = 4096
output_handler =
zlib.output_compression = Off
implicit_flush = Off
allow_call_time_pass_reference = Off
safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
disable_functions =
highlight.string  = #CC0000
highlight.comment = #FF9900
highlight.keyword = #006600
highlight.bg      = #FFFFFF
highlight.default = #0000CC
highlight.html    = #000000
expose_php = On
max_execution_time = 30     ; Maximum execution time of each script, in
seconds
memory_limit = 8M      ; Maximum amount of memory a script may consume
(8MB)
error_reporting  =  E_ALL
display_errors = Off
display_startup_errors = Off
log_errors = On
track_errors = Off
warn_plus_overloading = Off
variables_order = "GPCS"
register_globals = Off
register_argc_argv = Off
post_max_size = 8M
pc_order = "GPC"
magic_quotes_gpc = Off
magic_quotes_runtime = Off    
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root =
user_dir =
extension_dir = ./
enable_dl = On
file_uploads = On
upload_max_filesize = 2M
allow_url_fopen = On
[... unimportant module-config follows ...]
=================[php.ini]==================


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=14645&edit=1

Reply via email to