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

86
Views
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
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!