How to correct the Flaw in this function
class MyClass {
private $_callingscript;
public function __construct(){
$this->_callingscript= basename($_SERVER['SCRIPT_NAME']);
}
public static function Setvalue($k,$v){
if (!empty($k)) {
$_SESSION[$this->_callingscript.'_'.$k]= $v;//This doesnot work
$_SESSION[$_SERVER['SCRIPT_NAME'].'_'.$k]=$v //This works
}
}
}
MyClass::setValue('Somename',"Somevalue");
When i call this it is giving me error "Using $this
when not in object context in".
How to correct the callingscript variable .Is this due to private declaration of that variable