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

157
Views
PHP not recognizing JS variable as null

I have a javascript variable that I'm trying to send to a PHP function as null in order to test how it's registering in PHP, however, no matter what I've tried PHP won't register it as null. I've tried:

let testValue = null

and

let testValue = NULL

but the first still registers with PHP as not being null and the 2nd fails in my console and says NULL is not defined

PHP is looking for it like so:

    if(is_null($testValue)){
        dd('null');
    }else{
        dd('not null');
    }

why won't the PHP function recognize my first example as being null?

UPDATE: JS Code with axios call:

let testValue = null;

axios({
  method: 'post',
  url: test,
  data:{
    testValue: testValue
  }
}).then(function (response) {
}).then function (error) {
});

PHP controller

public function testingCall(Request $r){
  $testValue = $r->testValue;

  var_dump($testValue);
  
  if(is_null($testValue)){
        dd('null');
    }else{
        dd('not null');
    }
}
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!