Using user input from browser as PHP code

Hello, what I’m trying to accomplish is using user input as PHP code. I obtain the user innput by reading specific areas in de browser html page using javascript and use AJAX to contact php and interprete this input on the server. This input isn’t all that variable as it might soud, it always is a mathematical expression like (A = B + C) or something like that. I want to use that expression, specified by the user in the browser, in PHP and execute the expression being PHP code. I’ve been trying the eval(string) function in PHP which takes a string and interpretes it as PHP code. For some reason this doesn’t work well for me since I got the impression that the result of the eval fucntion doesn’t bind to a variable. Hence my question: what would be the preferred way to handle the user input being PHP executable code and how to do that?

Sponsor our Newsletter | Privacy Policy | Terms of Service