Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

88
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda