I have the following code in PHP:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
include '../model/class/classUser.php';
$UserNow = new User();
$UserNow->setName(htmlspecialchars($_POST['name']));
$UserNow->setUsername(htmlspecialchars($_POST['username']));
$UserNow->setYourOcupation(htmlspecialchars($_POST['yourOcupation']));
$UserNow->setYourGraduation(htmlspecialchars($_POST['yourGraduation']));
$UserNow->setEmail(htmlspecialchars($_POST['email']));
$UserNow->setPassword(htmlspecialchars($_POST['password']));
$RPassword=htmlspecialchars($_POST['rPassword']);
$x=$UserNow->getName();
echo "
$UserNow->getName();
";
?>
</body>
</html>
The code does not work and the browser warns that the getName function is undefined. But when I do this:
<?
...
$x=$UserNow->getName();
echo "
$x
";
?>
so it works . But I do not want to have to create temporary variables every time I use a class. What should I do to display the get get of the class?