I'm new in OOP php and i'm creating add to cart class but count variable is not working inside of add function and it is giving an error:
"Notice: Undefined variable: count"
Here is my code :
<?php
Class cart{
public $count=0;
public function add(){
@session_start();
$_SESSION['count'] = $count++;
echo $_SESSION['count'];
}
public function check(){
if(isset($_POST['sub'])){
$this->add();
}
}
}
$obj = new cart;
$obj->check();
?>