John Davidson

php - Escape quotes on onclick metho

0 comments
Message:


I have click method generated by php echo. It does not render as it should be. It shows as in the attached image.


my code is


echo "<div class='col-sm-3' onclick='ViewItem('".$item['item_id']."')' style='cursor:pointer'>";

how can I escape the quotes to get the following


<div class='col-sm-3' onclick='ViewItem("1")' style='cursor:pointer'>



My Answer:
"";

This code will escape the quotes properly and render the onclick method correctly.

Rate this post

5 of 5 based on 5044 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us