It echoes "nothing" because your browser doesn't understand <?php
tags, so it won't show the tag contents; it should show something when you select view the page source though.
The reason for this behaviour is that the default content type of your script is set as text/html
(you can confirm this by looking at the response headers) and in the context of HTML, you should use htmlspecialchars()
echo htmlspecialchars($var);
In fact, as a general rule, you should always escape variables appropriately when you output them.
Alternatively you could let the browser know that your output should not be interpreted as HTML; you can do this by setting an appropriate response header:
header('Content-Type: text/plain');
With the above content type your output is shown verbatim by the browser.