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

87
Visualizações
PHP converts Javascript incorrectly for inline arrow functions and changes quotes

PHP is converting single and double quotes: ' and " into the characters: ’ and ” (https://unicode-table.com/en/2019/ and https://unicode-table.com/en/201D/) (right single quotation mark and right double quotation mark)

It only does this in arrow functions:

Doesn't work:

<div class="modal onclick="(() => { console.log('test button clicked'); })()">
 <!-- modal contents -->
</div>

PHP spits out the wrong quotes: incorrect HTML

onclick="(() => { console.log(‘test button clicked’); })()”

Does work:

<div class="modal onclick="console.log('test button clicked')">
 <!-- modal contents -->
</div>

PHP spits out: correct HTML

onclick="(() => console.log('test button clicked')"

This is only in .php files; In a .html file this works fine:

onclick="(() => { console.log('test button clicked'); })()"

This means that I cannot use an arrow function inline in an HTML element because PHP incorrectly converts the quotes to unicode quote characters which renders those quotes to the DOM and the browser then continues to handle the rest of the page (as it should) as within double quotes and inside of the onclick (as it should) until it encounters another double quote from another HTML property.

The rest of the DOM

I am using PHP 8.0.0. I've tried researching this and can't find anything else about it. As bold of a claim as it is, I believe I've found a bug in PHP, although I'd like someone more qualified than I to determine that.

almost 4 years ago · Santiago Trujillo
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