Use javascript instead. PHP is not meant to do that.
PHP runs on server side but javascript runs on client side.
<html>
<head>
<script>
function myFunc(){
document.getElementById('content').innerHTML = "Hello world";
}
</script>
</head>
<body>
<button type="button" onclick="myFunc()">Click</button><div id="content"></div>
</body>
</html>
jsFiddle
To understand it simply, the PHP interpreter first pre-process your PHP file (hence its name - PHP: Hypertext Preprocessor), and interpret anything inside <?php and ?> tags and turn it into HTML, response header, and so on...
In your case, you define a PHP function and that's all. The function is unused - but the interpreter doesn't care.
After that, the server sends the preprocessed HTML to client side, and anything inside PHP tags are stripped.
Client (mostly, web browsers) will then parse the HTML as is. Client does not receive any PHP at all as they are gone before they are sent, and of course, the browser won't see your PHP function.
And yes, if the PHP depends on client input, you have to use form submission, Ajax, or anything like that.