php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5999 Problems with class
Submitted: 2000-08-07 01:14 UTC Modified: 2000-08-07 01:48 UTC
From: dfr at artelecom dot ru Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.0 OS: Windows 2000
Private report: No CVE-ID: None
 [2000-08-07 01:14 UTC] dfr at artelecom dot ru
Hello,

This code isn't work under PHP4:
<?
class Cart {
    var $items;
    function add_item($num) {
        $this->items += $num;
    }
    function get_items() {
      return $this->items;
    }
}

$nnn = new Cart;
$nnn->add_item(10);
list($itm) = $nnn->get_items();
echo "Items: $itm<br>";

$nnn->add_item(100);
list($itm) = $nnn->get_items();
echo "Items: $itm<br>";
?>

I have nothing on output here

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-07 01:48 UTC] hholzgra@php.net
applying list() on a function _not_ returning an arry 
does not make sense, use the return_value itself instead

replace list($itm) with $itm and all works well

list($itm) will result in $itm not even being defined 
if applied on a non-array ( isset($img)=false )
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 10:00:02 2026 UTC