خرید بک لینک

Vote count: 0

<?php

class Foo{
    public $basket;

    public function __construct()
    {
        $this->basket = 1;
    }

    public function getBasket(){
        retu $this->basket;
    }
}

class Bar{
    public function __construct(&$basket)
    {
        $basket++;
    }
}

$newFoo = new Foo();
$newBar = new Bar($newFoo->getBasket());

echo $newFoo->getBasket();

?>

I am hoping to initialise the $basket value in one class and manipulate the same variable via another class. Unfortunately, I keep getting the "Notice: Only variables should be passed by reference in " error message.

Question: How can I change the code to make this happen? Thank you.

asked 21 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 18 مرداد 1395 ساعت: 13:12

صفحه بندی