You declare a private variable inside the method, which is not possible.
If you want ac have private variables, you would need to declare them in the class definition:
class ac { private $plain_username = $_POST['username']; private $md5_password = md5($_POST['password']);
and access them in class methods using
public function authentication() { echo $this->plain_username;
By the way, the operator assigning md5_password will not work - you cannot use functions in class definitions.
You will need to do the md5 calculation in the class constructor, which would be a cleaner way of doing assignments. In the class add:
function __construct ($plain_username, $password) { $this->plain_username = $plain_username; $this->md5_password = md5 ($password); }
and then initialize the class:
$ac = new ac($_POST["username"], $_POST["password"]);
source share