jokemiri jokemiri - 6 months ago 10
PHP Question

How do I escape quotes in url

Please I have a little knowledge on this, I want to insert url all into single quotes. I have tried using both single and double wuotes, but not working. I checked this question - Escaping single quote in url link, but did not help

<?php
echo '\'' base_url().'\'index.php?admin/product/delete/1\'';
echo '\''; echo base_url().index.php?admin/product/delete/1\'';
echo '\'. base_url().index.php?admin/product/delete/1\'';
echo "\'"; echo base_url().'index.php?admin/product/delete/1\'";
?>


I am trying to achieve this:
'http://localhost/my_site/index.php?admin/product/delete/1'

the url in single quotes

Answer

If you really want to use only single quotes, try this:

echo '\''.base_url().'index.php?admin/product/delete/1\'';