I'm trying to do something with PHP when a text box changes. I can do this with JavaScript with onchange but that doesn't work with PHP.
I already have a PHP function in my already existing PHP code. When a text box value changes, I want it to run the function.
The reason you can do it in JavaScript is because you're in the same scope...the client side. PHP is a server-side language, so it has no notion of what is happening on the client-side, unless you explicitly tell it.
To tell PHP to evaluate, and possible return the response of a function call, you have to pass it the value of the input using a network call, such as a fetch or ajax request.
Your question shows that you really don't understand PHP, and you need to learn the fundamentals of it. PHP does not run client-side, and JavaScript does not run server-side (again, unless you're using Node, in which case you wouldn't be using PHP).