<?php
class Student { public $name = "Benjamin"; }
$name = new Student();
?>
<p>Hello, there. My name is <?php $name->name ?></p>
The above code doesn't work as intended (printing the name within "p" tags). But the below code, of course, does work:
<?php
class Student { public $name = "Benjamin"; }
$name = new Student();
echo '<p>Hello, there. My name is ' . $name->name . '</p>';
?>
Is the class being destructed when closing PHP tags?
Is there a work-around for the second code example?
Thanks, as always.