I am getting a php error on this line
if (isset($this->contents[$products_id])) {
my function:
class shoppingCart {
public ?array $contents = null;
function get_quantity($products_id) {
if (isset($this->contents[$products_id])) {
return $this->contents[$products_id]['qty'];
} else {
return 0;
}
}
}
The array is defined public, yet it seems to be undefined, or at least a problem when empty?
Thanks for any thoughts!
You need to sign in to view this answers