Bug #2971 [Com]: Misbehaved instance variables in classes

From: Date: Wed, 01 Sep 2021 18:05:55 +0000
Subject: Bug #2971 [Com]: Misbehaved instance variables in classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236243@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=2971&edit=1 ID: 2971 Comment by: lildurk2971 at gmail dot com Reported by: ojapp at skip-consulting dot de Summary: Misbehaved instance variables in classes Status: Not a bug Type: Bug Package: Other Operating System: Linux Suse 6.2 PHP Version: 3.0.11 Block user comment: N Private report: N New Comment: Lil Durk is a private agency dedicated to providing responsible access to legal cannabis for adults aged 19 and older. We’re an exclusively online retailer and wholesaler for recreational cannabis and a trusted source for information about cannabis and cannabis-related issues. We believe our work is meaningful and we take pride in our mandate to promote the socially responsible use of legal cannabis. https://lildurk.com/ Previous Comments: ------------------------------------------------------------------------ [2002-10-01 10:32:43] hholzgra@php.net In PHP 3 and 4 Objects are copied on assignment by default. In PHP 3 there is no easy way to get around this, in PHP 4 it is possible to return references from functions and methods. The situation will improve greatly in the upcoming PHP 5 with Zend Engine 2 ------------------------------------------------------------------------ [1999-12-13 18:57:46] ojapp at skip-consulting dot de Hi, I got a little problem with the following script. The member vars are not set properly. <?php class Option { function Option() { return $this; } } class Select { var $options; var $optionCount=0; function Select() { return $this; } function addOption() { $this->options[$this->optionCount++] = new Option(); echo 'select.addOption() called... optionCount ='.$this->optionCount.'<br>'; } function create() { echo 'select.create() called... optionCount ='.$this->optionCount.'<br>'; } } class Dialog { var $sel; function Dialog() { return $this; } function addSelect() { $this->sel = new Select(); return $this->sel; } function create() { $this->sel->create(); } } $d = new Dialog(); $a = $d->addSelect(); $a->addOption(); $a->addOption(); $d->create(); ?> this script puts out select.addOption() called... optionCount =1 select.addOption() called... optionCount =2 select.create() called... optionCount =0 but it should put out select.addOption() called... optionCount =1 select.addOption() called... optionCount =2 select.create() called... optionCount =2 The member var optionCount is'nt set well. Regards Olaf Japp ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=2971&edit=1

« previous php.bugs (#236243) next »