PHP cannot be run in the browser like javascript.
PHP runs on the server like <?php echo "test"; ?>
. PHP must be installed on the server, first, as well.
To run your PHP code in "real-time," look into ajax requests. If setup correctly, you can type PHP code on your page, have it sent to the server, and get a response from the server with the output of the PHP code without refreshing the page.