Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
Passing Value from Javascript to PHP not working?

I tried to show a different content based on detecting user's browser language. 1.It seems I can get the language setting value from javascript. 2.I can also echo it out in php. But for some reason, when I out it inside "if statement" (see below), it seems not working? Which part I did wrong? Thanks in advance.

<script>
              let test_lang;
              test_lang = navigator.language;
              if(test_lang == "en"){
                console.log("yes, this is en");
                document.writeln(test_lang);
              }
              <?php
               $test_lang ="<script>document.write(test_lang);</script>";
               ?>
            </script>


            <?php
            echo '$test_lang:'.$test_lang;

            if($test_lang == 'en'){
              echo 'php en';
            }
?>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!