Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda