How to decode string on PHP page

Asked

Viewed 55 times

1

I can’t display on a pure screen of PHP, one echo

Erro

header('Content-Type: text/html; charset=utf-8');

if (!isset($_GET["solicitacao"])) {
$string = "Não há uma solicitação Informada";
echo utf8_encode($string);
}elseif ($_GET["solicitacao"] == "DATAS_DISPONIVEIS") {
    $dtas_disponiveis = array("02/02/2019", "20/02/2019");  
    $myJSON = json_encode($dtas_disponiveis);
    echo $myJSON;
}else{
    echo "Deu em nada!";
}
  • 1

    I got it!! I just had to get the "utf8_encode out of echo"

1 answer

2


I believe your problem is related to 2 charset's in the scope of your file .php.
Try to remove the charset=utf-8 existing in the header and maintain the echo utf8_encode($string); or try to change the echo utf8_encode($string); for echo $string;

  • 1

    Okay, that was it!! Thank you!!! I took the meeting.!!

  • 1

    Tag as response

  • I am happy to be able to clarify something. If you think the answer was useful, it is worth accepting it as useful thus facilitating life for those with the same problem. Thank you for the reinforcement, Vinicius De Jesus.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.