Skip to content
Advertisement

cannot print url data in a required format via php

I need to get url data printed in the following format below

https://mysite/data/api?q="'xxxxx' in contents"

but each time i run the code below am getting something like this below which is not what I want

https://mysite/data/api?q=xxxxx in contents

here is what I have tried

$my_id  = 'xxxxx';
$myurl= "https://mysite/data/api?q={$my_id}";
echo $myurl . " in contents";

Advertisement

Answer

Try like this HTML code in your variable declaration:

<?php 
$my_id  = '&#34;&#39;xxxxx&#39;';
$myurl= "https://mysite/data/api?q={$my_id}";
echo $myurl . " in contents&#34; ";
?>

You will get the output like this:

https://mysite/data/api?q="'xxxxx' in contents"
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement