Its not possible to call php method directly, it gives error not defined as there is no method print_hello in the javascript file.
ReferenceError: print_hello is not defined
You have to use AJAX to call a php method from the javascript.
AJAX, is little bit tricky, if you want to make it simple you can use jQuery library.
You have to include your code in the print_hello method in a file and call the file using AJAX. Let say you have put the method print_hello in a file print_hello.php, the sample code will be:
$.ajax({
url: "print_hello.php"
}).done(function() {
alert( "called php code succesfully" );
});
And put your php code in file php_hello.php
<?php
print_hello();
?>
More info on how to make ajax call found at
Ajax jQuery
NOTE: ( as you are new to web development)
Web development is all about communication. In this case,
communication between 2 parties, over the HTTP protocol:
The Server - This party is responsible for serving pages.
The Client - This party requests pages from the Server, and displays them to the
user. On most cases, the client is a web browser. The User - The user
uses the Client in order to surf the web, fill in forms, watch videos
online, etc. Each side's programming, refers to code which runs at the
specific machine, the server's or the client's.
More info At this StackOverflow Question (server side and client side programming)