How to access and receive variables from PHP files using HTTP requests?
I received an HTTP request to my .PHP file. Next what I want to do is for example reference I want to receive $testvariable = 1;
back but I don't know where to start. The HTTP parameters don't actually let me reference this $testvariable directly.
What if the PHP file has only one function, and return $testvariable;
is executed at the end of it? Will HTTP receive this variable? What if I need more than one? Maybe try having PHP put the parameters in the URL and then HTTP read those parameters in the URL? Maybe these "titles" are the key...
P粉3443557152024-01-30 12:05:57
I see. HTTP requests return all the content on the HTML page. It seems to ignore the tags, but everything else in the body will be taken back in your response. Even if your answer is
" 1 "
but there is a space around your answer, your answer is 1 (including the space). You need a clean "1"
.
Pass variables by using content fields. You place values and assign them to strings like number=
and then post it on the page. When the page loads, it can look for a variable with the same name, for example $test = $_POST['number']; and get the value in that variable and use it further on your page if needed.