php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3760 Assignment of a value to on member variable of a class affects (all ) others.
Submitted: 2000-03-07 20:41 UTC Modified: 2000-03-08 08:56 UTC
From: heino at bigfoot dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Beta 4 Patch Level 1 OS: Linux/Redhat 6.1
Private report: No CVE-ID: None
 [2000-03-07 20:41 UTC] heino at bigfoot dot com
Whem assigning a value to a internal class-variable all of them is assigned that value!

Minor example follows =);-D



---------------------- SysInfo Start -----------------------
OS: Linux 2.2.12/Redhat 6.1
HTTPD: Apache 3.1.12
ARCH: i386(+586) (Pentium/std 133)
libxml: 1.8.7
---------------------- SysInfo End -------------------------




-------------------- Install.sh Start ----------------------
#!/bin/sh
./configure \
    --with-apxs=/opt/apache/sbin/apxs \
    --disable-debug \
    --enable-track-vars \
    --enable-xml \
    --disable-short-tags \
    --enable-url-includes \
    --with-dom
make 
make install
-------------------- Install.sh End ------------------------
NOTE: -lgz changed to -lz in configure to make --with-dom/libxml work











--------------------- Example Start ----------------------
<?php
header("Content-type: text/plain");
?>

<h1>Example 1</h1>

<?php

class e1 {
    var $a = 1;
    var $b;
    var $c;
    var $d;
    function e1($i) {
	$this->$b = 2;
	$this->$c = $i;
    }
}

$e1 = new e1(3);

echo "<table border=1>";
echo "<tr><th></th><th>Expected</th><th>I got</th><th>You got</th></tr>";
echo "<tr align=\"center\"><td>\$a</td><td>\"1\"</td><td>\"3\"</td><td>\"".$e1->$a."\"</td></tr>";
echo "<tr align=\"center\"><td>\$b</td><td>\"2\"</td><td>\"3\"</td><td>\"".$e1->$b."\"</td></tr>";
echo "<tr align=\"center\"><td>\$c</td><td>\"3\"</td><td>\"3\"</td><td>\"".$e1->$c."\"</td></tr>";
echo "<tr align=\"center\"><td>\$d</td><td>\"\"</td><td>\"3\"</td><td>\"".$e1->$d."\"</td></tr>";
echo "</table>";
?>






<h1>Example 2</h1>

<?php

class e2 {
    var $a = 1;
    var $b;
    var $c;
    var $d;
    function e2($i) {
	$this->$b = 2;
#	$this->$c = $i;
    }
}

$e2 = new e2(3);

echo "<table border=1>";
echo "<tr><th></th><th>Expected</th><th>I got</th><th>You got</th></tr>";
echo "<tr align=\"center\"><td>\$a</td><td>\"1\"</td><td>\"2\"</td><td>\"".$e2->$a."\"</td></tr>";
echo "<tr align=\"center\"><td>\$b</td><td>\"2\"</td><td>\"2\"</td><td>\"".$e2->$b."\"</td></tr>";
echo "<tr align=\"center\"><td>\$c</td><td>\"\"</td><td>\"2\"</td><td>\"".$e2->$c."\"</td></tr>";
echo "<tr align=\"center\"><td>\$d</td><td>\"\"</td><td>\"2\"</td><td>\"".$e2->$d."\"</td></tr>";
echo "</table>";
?>






<h1>Example 3</h1>

<?php

class e3 {
    var $a = 1;
    var $b;
    var $c;
    var $d;
    function e3($i) {
#	$this->$b = 2;
#	$this->$c = $i;
    }
}

$e3 = new e3(3);

echo "<table border=1>";
echo "<tr><th></th><th>Expected</th><th>I got</th><th>You got</th></tr>";
echo "<tr align=\"center\"><td>\$a</td><td>\"1\"</td><td>\"\"</td><td>\"".$e3->$a."\"</td></tr>";
echo "<tr align=\"center\"><td>\$b</td><td>\"\"</td><td>\"\"</td><td>\"".$e3->$b."\"</td></tr>";
echo "<tr align=\"center\"><td>\$c</td><td>\"\"</td><td>\"\"</td><td>\"".$e3->$c."\"</td></tr>";
echo "<tr align=\"center\"><td>\$d</td><td>\"\"</td><td>\"\"</td><td>\"".$e3->$d."\"</td></tr>";
echo "</table>";
?>






<h1>Example 4</h1>

<?php

class e4 {
    var $a = 1;
    var $b;
    var $c;
    var $d;
    function e4($i) {
#	$this->$b = 2;
#	$this->$c = $i;
    }
}

$e4 = new e4(3);
$e4->$d = 4;
echo "<table border=1>";
echo "<tr><th></th><th>Expected</th><th>I got</th><th>You got</th></tr>";
echo "<tr align=\"center\"><td>\$a</td><td>\"1\"</td><td>\"4\"</td><td>\"".$e4->$a."\"</td></tr>";
echo "<tr align=\"center\"><td>\$b</td><td>\"\"</td><td>\"4\"</td><td>\"".$e4->$b."\"</td></tr>";
echo "<tr align=\"center\"><td>\$c</td><td>\"\"</td><td>\"4\"</td><td>\"".$e4->$c."\"</td></tr>";
echo "<tr align=\"center\"><td>\$d</td><td>\"4\"</td><td>\"4\"</td><td>\"".$e4->$d."\"</td></tr>";
echo "</table>";
?>





<h1>Example 5</h1>

<?php

class e5 {
    var $a = 1;
    var $b;
    var $c;
    var $d;
    function e5($i) {
#	$this->$b = 2;
#	$this->$c = $i;
    }
}

$e5 = new e5(3);
$e5->$d = 4;
$e5->$a = 0;
echo "<table border=1>";
echo "<tr><th></th><th>Expected</th><th>I got</th><th>You got</th></tr>";
echo "<tr align=\"center\"><td>\$a</td><td>\"1\"</td><td>\"\"</td><td>\"".$e5->$a."\"</td></tr>";
echo "<tr align=\"center\"><td>\$b</td><td>\"\"</td><td>\"\"</td><td>\"".$e5->$b."\"</td></tr>";
echo "<tr align=\"center\"><td>\$c</td><td>\"\"</td><td>\"\"</td><td>\"".$e5->$c."\"</td></tr>";
echo "<tr align=\"center\"><td>\$d</td><td>\"4\"</td><td>\"\"</td><td>\"".$e5->$d."\"</td></tr>";
echo "</table>";
?>
----------------------- Example End ------------------------








------------------- Configure Log Start --------------------
loading cache ./config.cache

Running system checks
checking for a BSD compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... yes
checking for working aclocal... found
checking for working autoconf... found
checking for working automake... found
checking for working autoheader... found
checking for working makeinfo... found
checking whether to enable maintainer-specific portions of Makefiles... no
checking for bison... bison -y
checking bison version... 1.28 (ok)
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking how to run the C preprocessor... gcc -E
checking for AIX... no
checking for gcc option to accept ANSI C... none needed
checking for ranlib... ranlib
checking whether gcc and cc understand -c and -o together... yes
checking whether ln -s works... yes
checking for flex... flex
checking for flex... (cached) flex
checking for yywrap in -lfl... yes
checking lex output file root... lex.yy
checking whether yytext is a pointer... yes
checking for working const... yes
checking whether compiler supports -R... no
checking whether compiler supports -Wl,-rpath,... yes
checking for sendmail... /usr/sbin/sendmail
checking for gethostname in -lnsl... yes
checking for socket in -lsocket... no
checking for htonl in -lsocket... no
checking for gethostbyaddr in -lnsl... yes
checking for crypt in -lcrypt... yes
checking for sin in -lm... yes
checking for inet_aton in -lbind... no
checking for inet_aton in -lresolv... yes
checking for res_search in -lsocket... no
checking for res_search in -lresolv... yes
checking for ANSI C header files... yes
checking for dirent.h that defines DIR... yes
checking for opendir in -ldir... no
checking for fclose declaration... ok
checking for arpa/inet.h... yes
checking for crypt.h... yes
checking for dlfcn.h... yes
checking for fcntl.h... yes
checking for grp.h... yes
checking for limits.h... yes
checking for locale.h... yes
checking for memory.h... yes
checking for netinet/in.h... yes
checking for pwd.h... yes
checking for signal.h... yes
checking for stdarg.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for sys/file.h... yes
checking for sys/mman.h... yes
checking for sys/select.h... yes
checking for sys/socket.h... yes
checking for sys/statfs.h... yes
checking for sys/statvfs.h... yes
checking for sys/time.h... yes
checking for sys/types.h... yes
checking for sys/varargs.h... no
checking for sys/wait.h... yes
checking for syslog.h... yes
checking for unistd.h... yes
checking for unix.h... no
checking whether struct tm is in sys/time.h or time.h... time.h
checking for tm_zone in struct tm... yes
checking for tm_gmtoff in struct tm... yes
checking for struct flock... yes
checking for socklen_t... yes
checking size of long... 4
checking size of int... 4
checking for st_blksize in struct stat... yes
checking for st_blocks in struct stat... yes
checking for st_rdev in struct stat... yes
checking for size_t... yes
checking for uid_t in sys/types.h... yes
checking for uint... yes
checking for ulong... yes
checking for vprintf... yes
checking for asctime_r... yes
checking for crypt... yes
checking for ctime_r... yes
checking for cuserid... yes
checking for flock... yes
checking for gcvt... yes
checking for getlogin... yes
checking for gethostbyaddr... yes
checking for gettimeofday... yes
checking for gmtime_r... yes
checking for inet_aton... yes
checking for link... yes
checking for localtime_r... yes
checking for lockf... yes
checking for lrand48... yes
checking for memcpy... yes
checking for memmove... yes
checking for mmap... yes
checking for putenv... yes
checking for random... yes
checking for rand_r... yes
checking for regcomp... yes
checking for rint... yes
checking for setitimer... yes
checking for setlocale... yes
checking for setsockopt... yes
checking for setvbuf... yes
checking for shutdown... yes
checking for sin... yes
checking for snprintf... yes
checking for srand48... yes
checking for srandom... yes
checking for statfs... yes
checking for statvfs... yes
checking for strcasecmp... yes
checking for strdup... yes
checking for strerror... yes
checking for strftime... yes
checking for strstr... yes
checking for strtok_r... yes
checking for symlink... yes
checking for tempnam... yes
checking for tzset... yes
checking for unsetenv... yes
checking for usleep... yes
checking for utime... yes
checking for vsnprintf... yes
checking for strlcat... no
checking for strlcpy... no
checking for getopt... yes
checking whether utime accepts a null argument... yes
checking for working alloca.h... yes
checking for alloca... yes
checking whether sprintf is broken... no
checking for declared timezone... yes
checking whether to use a configuration file... yes
checking whether to include debugging symbols... no
checking whether to enable safe mode by default... no
checking for safe mode exec dir... /usr/local/php/bin
checking whether to enable track_vars variables by default... yes
checking whether to enable magic quotes by default... no
checking whether to enable runpaths... yes
checking whether to enable short tags by default... no
checking whether to enable the URL-aware fopen wrapper... yes
checking whether to enable dmalloc... no
checking whether to install PEAR... yes

Configuring SAPI modules
checking for AOLserver support... no
checking for Apache module support via DSO through APXS... yes
checking for mod_charset compatibility option... no
checking for fhttpd module support... no
checking for Zeus ISAPI support... no
checking for PHTTPD support... no
checking for Roxen/Pike support... no
checking for Servlet support... no
checking for thttpd... no
checking for chosen SAPI module... apache

Configuring extensions
checking for ASPELL support... no
checking whether to enable bc style precision math functions... no
checking whether to include cpdflib support... no
checking for CyberCash support... no
checking whether to enable DAV support through mod_dav... no
checking for db1/ndbm.h... yes
checking for gdbm_open in -lgdbm... yes
checking preferred dbm library... gdbm chosen
checking for gdbm.h... yes
checking for GDBM support... no
checking for NDBM support... no
checking for Berkeley DB2 support... no
checking for Berkeley DB3 support... no
checking for DBM support... no
checking for CDB support... no
checking whether to enable DBA interface... no
checking whether to include the bundled dbase library... no
checking whether to include DOM support... yes
checking for xmlNewDoc in -lxml... yes
checking whether to include fdftk support... no
checking whether to include the bundled filePro support... no
checking for FTP support... no
checking whether to include GD support... checking for gdImageLine in -lgd... yes
checking for gdImageString16 in -lgd... yes
checking for gdImageString16 in -lgd... (cached) yes
checking for compress in -lz... yes
checking for png_info_init in -lpng... yes
checking for gdImageColorResolve in -lgd... no
checking for gdImageCreateFromPng in -lgd... no
checking for gdImageCreateFromGif in -lgd... yes
checking whether to include ttf support... no
checking whether to enable 4bit antialias hack with FreeType2... no
checking whether to include GNU gettext support... no
checking for Hyperwave support... no
checking for ICAP support... no
checking for IMAP support... no
checking for Informix support... no
checking for InterBase support... no
checking for Java support... no
checking for LDAP support... no
checking for MCAL support... no
checking for mcrypt support... no
checking for mhash support... no
checking for mSQL support... no
checking for MySQL support... no
checking for Oracle-OCI8 support... no
checking for Adabas support... no
checking for Solid support... no
checking for IBM DB2 support... no
checking for Empress support... no
checking for Velocis support... no
checking for a custom ODBC support... no
checking for iODBC support... no
checking for Easysoft ODBC-ODBC Bridge support... no
checking for unixODBC support... no
checking for OpenLink ODBC support... no
checking for DBMaker support... no
checking for Oracle support... no
checking whether to include PCRE support... yes
checking for memmove... (cached) yes
checking whether to include Pdflib 2.x support... no
checking for PostgresSQL support... no
checking whether to include POSIX-like functions... yes
checking for readline support... no
checking for mm support... no
checking whether to enable transparent session id propagation... no
checking for SNMP support... no
checking whether to enable UCD SNMP hack... no
checking for dlopen in -lc... no
checking for dlopen in -ldl... yes
checking for pam_start in -lpam... yes
checking for crypt in -lcrypt... (cached) yes
checking for getcwd... yes
checking for getwd... yes
checking for standard DES crypt... yes
checking for extended DES crypt... no
checking for MD5 crypt... yes
checking for Blowfish crypt... no
checking for Sybase support... no
checking for Sybase-CT support... no
checking whether to enable System V semaphore support... no
checking whether to enable System V shared memory support... no
checking whether to include WDDX support... no
checking whether byte ordering is bigendian... no
checking for XML support... yes
checking whether to include YP support... no
checking whether to include zlib support... no
checking whether to enable versioning... no
checking which regex library to use... php

Configuring Zend
checking bison version... 1.28 (ok)
checking for limits.h... (cached) yes
checking for malloc.h... yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking for stdarg.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for signal.h... (cached) yes
checking for unix.h... (cached) no
checking for dlfcn.h... (cached) yes
checking for size_t... (cached) yes
checking return type of signal handlers... void
checking for dlopen in -lc... (cached) no
checking for dlopen in -ldl... (cached) yes
checking for uint... (cached) yes
checking for ulong... (cached) yes
checking for vprintf... (cached) yes
checking for 8-bit clean memcmp... yes
checking for working alloca.h... (cached) yes
checking for alloca... (cached) yes
checking for memcpy... (cached) yes
checking for strdup... (cached) yes
checking for getpid... yes
checking for kill... yes
checking for strtod... yes
checking for strtol... yes
checking whether sprintf is broken... (cached) no
checking whether to enable experimental ZTS... no
checking whether to enable inline optimization for GCC... no
checking whether to enable a memory limit... no
checking whether to enable Zend debugging... no
checking for inline... inline

Configuring libtool
checking host system type... i586-pc-linux-gnu
checking build system type... i586-pc-linux-gnu
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD-compatible nm... /usr/bin/nm -B
updating cache ./config.cache
checking for object suffix... o
checking for executable suffix... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.lo... yes
checking if gcc supports -fno-rtti -fno-exceptions ... yes
checking if gcc static flag -static works... -static
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the linker (/usr/bin/ld) supports shared libraries... yes
checking command to parse /usr/bin/nm -B output... ok
checking how to hardcode library paths into programs... immediate
checking for /usr/bin/ld option to reload object files... -r
checking dynamic linker characteristics... Linux ld.so
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for objdir... .libs
creating libtool
loading cache ./config.cache

Generating files
checking for working mkdir -p... yes
creating config_vars.mk
creating sapi/Makefile
creating ext/Makefile
creating Makefile
creating pear/Makefile
creating ext/db/Makefile
creating ext/domxml/Makefile
creating ext/gd/Makefile
creating ext/pcre/Makefile
creating ext/pcre/pcrelib/Makefile
creating ext/posix/Makefile
creating ext/session/Makefile
creating ext/standard/Makefile
creating ext/xml/Makefile
creating ext/xml/expat/Makefile
creating ext/xml/expat/xmlparse/Makefile
creating ext/xml/expat/xmltok/Makefile
creating sapi/apache/Makefile
creating regex/Makefile
updating cache ./config.cache
creating ./config.status
creating php4.spec
creating Zend/Makefile
creating scripts/mkextlib
creating build-defs.h
creating php_config.h
creating internal_functions.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+
------------------- Configure Log End --------------------








Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-08 08:56 UTC] andrei at cvs dot php dot net
I believe the source of your troubles is that you're not using the
class variables correctly. You do:

$this->$a

instead of

$this->a.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 12:01:31 2024 UTC