You have PHP and JavaScript mixed up here - you'll need to understand the concept, give it some thought.
PHP is dynamic on the SERVER, but apache still only sends static HTML to the browser. The static HTML can contain javascript which is the only thing that can do that kind of thing IN THE CLIENT'S BROWSER. Think about it. Now, you can use php to dynamically place variables or lines IN JavaScript, but there is no way the end user can call a php function from the browser. In fact, the user can't even see the php code, only the result of that code.
It's a pretty concise boundary between the two; once you understand it you'll have it from then on, and there are amazing things you can do with both of them, but just remember a user can't click a button etc. and access a php function - only a javascript function.
Cheers,
Samuel