Dear all,
How i send parameters using php file_get_content function.
$id='123';
$name='blah';
$response=file_get_contents('http://localhost/abc/abc.php?id=$id&name=$name');
echo $response;
I need to send the $id and name value to abc.php page.Here the value passing does not working.also i chk ?id="$id"&name="$name" value.It's also not working. But the straite parameter works.say-
$response=file_get_contents('http://localhost/abc/abc.php?id=123&name=blah');
Now is their any Kind heart who can help me to send the 2 parameters $id and $name to abc.php?
Thanks
riad
If you want to enable variable substitution in a string, you have to use double quotes:
$response=file_get_contents("http://localhost/abc/abc.php?id=$id&name=$name");
Single quotes inhibit variable substitution.
$response=file_get_contents("http://localhost/abc/abc.php?id=$id&name=$name");
Don't forget to URL-encode all parameters though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With