But you indeed misunderstood how this works. This is no apache quirks, wrong config or anything like this.
What your php code does right now is nothing more then displaying/returning the data the same client just sent. There is really no way that the value you see changes anyhow.
Your php code needs to do 2 different things to do what you want.
The first is to save/write the data a client sents somewhere, usually a database like sqlite or mysql will be used for this. (Or just use a simple file like the user "LauBaz" did who shared his solution on page 1 of this thread.)
The second is to read the data from there.
You could decide what to do based on the fact that a client sends some data. (Or just use 2 different php scripts and call them accordingly: e.g. write.php, read.php)
So if a client connects and sends some data your code should save it somewhere.
And if a client connects and doesn't sends any data your code should try to read the data from where you saved it.
Here are two sites that might help you: (Even though they not explain in detail how all this works)
https://primalcortex.wordpress.com/2015 ... -database/
http://afterhoursengineering.net/blog/b ... -database/