I'm doing an object-oriented system with php tag and I noticed that the following code does not work:
<?php
include 'User.php';
$temp_user = new User();
$temp_user->set_name(htmlspecialchars($_POST['name']));
$temp_user->set_user_name(htmlspecialchars($_POST['username']));
$temp_user->set_password(htmlspecialchars($_POST['password']));
//$local_name= $temp_user->get_name();
echo "<br>$temp_user->get_password()<br>"
?>
But the same code without directly sending the class method works:
include 'User.php';
$temp_user = new User();
$temp_user->set_name(htmlspecialchars($_POST['name']));
$temp_user->set_user_name(htmlspecialchars($_POST['username']));
$temp_user->set_password(htmlspecialchars($_POST['password']));
//$local_name= $temp_user->get_name();
$var1 = $temp_user->get_password();
echo "<br>$var1<br>"
. "<br><br>"
. "<br><br>";
?>
What could be wrong?
NOTE: All my methods are public