How to GET a READ from php into a variable (allways 1 or 0)

What is the point of the toSerial() function? It seems to take all the data and just send it to the Serial Monitor without saving any of it.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

...R