On submitting a form does the ensuing function have to be javascript or can it also be a .php function?

For example if i have a <form method= "POST" onSubmit="phpfunction(this);"

and then later: <?php function phpfunction(){some function} ?>

- Should I be able to run the php function when the form is submitted?
- is it OK that the form is not within "<?php ?>"
- what should go inside the parenthesis when defining the phpfunction?