How to post a term with brackets with PHP to Sympy
Question: I want to post a term like

    
    
    5+(x+4)
    

from PHP via Python to Sympy in order to simplify the expression.

For that I'm using folowing code: PHP:

    
    
    $param="5+(x+4)";
    $command="python $PathToPySkript $param"; //# '$param2' '$param3'";
    $buffer='';
    ob_start(); // prevent outputting till you are done
    passthru($command);  
    $buffer=ob_get_contents();
    ob_end_clean();
    

PY:

    
    
    import sys
    from sympy import *
    from sympy.parsing.sympy_parser import *
    from sympy.solvers import solve
    from sympy import Symbol
    x = Symbol('x')
    transformations=(standard_transformations + (implicit_multiplication_application,) + (function_exponentiation,)+(convert_xor,))      
    print(latex(parse_expr(sys.argv[1], transformations=transformations)))
    

I'm able to post terms like

    
    
    5+x+4
    

without any problem, retrieve the solution and display it on my website.

But for any term with brackets like ( or { or [, the processing throw errors
or I would get no notice in PHP.

I tried also to double the brackets like (( or {{ or [[ but this will have no
effekt.

Has anybody an idea how to get a solution for my problem.


Answer: Okay, I found a solution for myself! The problem was that I have set the
string like these:

PHP:

    
    
    $param="5+(x+4)";
    

I changed this to:

    
    
    $param="'5+(x+4)'";
    

Now it works as expected...

