<?php
class Pen
{
public $color;
public function clr()
{
$this->color = "Red";
}
public function write()
{
echo $this->color; //if i write $ before color it gives me an error
}
}
$a = new Pen();
$a->write();
?>
i tried to write an $ dollar in the write() function but it gives me an error and in this code it shows nothing i even tried to use "class name :: function name ()-> color ;" didn't work either i tried a lot of things that i found here but none of them really worked for me