If you use PHP for its major purpose, for Web programming, it will be impractical. Due to performance problems. The calculator already exists, you don't have to do anything. It's called "JavaScript". Just add some text area and call JavaScript
eval
function on its content?
Example? Please see how I use it:
http://sakryukov.org/freeware/calculator/[
^].
—SA