Why is the following code not working? The variables and function are not accesssed by the "$objkt".
<?php
print "This file displays function info.";
echo "<br/>";
class User
{
public $name="MyName";
public $pwd="PaSsWoRd";
function info()
{
print_r(ucfirst(strtolower($name)));
echo "<br/>";
print_r(ucfirst(strtolower($pwd)));
echo "<br/>";
}
}
$objkt = new User;
$objkt->name;
$objkt->pwd;
$objkt->info();
?>
.Output :
This file displays function info.
Notice: Undefined variable: name in C:\xampp\htdocs\project2\infotest.php on line 17
Fatal error: Cannot access empty property in C:\xampp\htdocs\project2\infotest.php on line 17