You cannot invoke PHP from JavaScript like that. You need AJAX: http://en.wikipedia.org/wiki/Ajax
Also, use unobtrusive JavaScript - attach event handlers in your Script code, not in the HTML. Basic example how to implement what you probably want, using jQuery:
// In your HTML page:
<scipt type="text/javascript">
$(document).ready(function() {
$('button').click(function() {
$.get("/hello.php", function(data) {
alert(data);
});
});
});
</script>
// In hello.php:
<?php
function hello() {
// ...
echo $return;
}
hello();
?>
You need to understand the distinction between server- and client-side processing. All your PHP code is executed on the server on each page request. The results are then sent to your browser, which displays them. Now there can be JavaScript code in your page, which is executed by the browser after the page is loaded. In order to invoke PHP code on a button click (or similar), this client-side code needs to make a new HTTP request to the server - this is what AJAX is for. This new request will trigger the execution of another PHP script. The results are transferred back to the JavaScript function after it finishes, and can then be used to do something, like adding additional content to your page.
addvote()run on each click orhello()function?hello()function will run on each page request