The interaction between PHP and JS

Source: Internet
Author: User
To hide a value from a form
$orderno = ";

if ($orderno = = "333")
{
echo ' OK '. $orderno;
}
else{
Echo ' NO2 ';
}

I want to use this method to pass the value of JS to PHP variable, the above code, echo $orderno when the value is 333, but why the following execution of the IF statement to always execute the content of else, why the value is not equal?? Urgent Request!! Thank you, guys.


Reply to discussion (solution)

PHP runs in front, JS runs in the back
After PHP runs, JS starts to run

So during an HTTP session:
JS can send data to PHP, and accept the data returned by PHP
Not in the opposite way.

But Echo can print out the document.write ("333"), this is how to explain, thank you thanks

This, of course, only executes the Else branch ... If you need to pass the value of JS to the PHP variable. Can I use the Ajax,dwr method?

But Echo can print out the document.write ("333"), this is how to explain, thank you thanks




Echo $orderno; The server-side parsing outputs a line of strings that should have seen "
But see 333, this is because the client script immediately output 333, this 333 is not the echo direct output value

-----------------
This question, to understand that PHP is a server-side operation, script---document.write is running on the client, there are sequencing
$orderno = ";
Echo GetType ($orderno); String
$orderno the current value is string string==333? Must not be true, so always perform else's content


Var_dump ($orderno); See the source code to see not 333

$orderno = ";

There must be something wrong with this print.


But Echo can print out the document.write ("333"), this is how to explain, thank you thanks




Echo $orderno; The server-side parsing outputs a line of strings that should have seen "
But see 333, this is because the client script immediately output 333, this 333 is not the echo direct output value

-----------------
This question, to understand that PHP is a server-side operation, script---document.write is running on the client, there are sequencing
$orderno = ";
Echo GetType ($orderno); String
$orderno the current value is string string==333? Must not be true, so always perform else's content


I understand, thank you very much!!
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.