Reputation: 17
How can I use the
.$_GET['id'];
After Domain.com
Like This
Domain.com/.$_GET['id'];
($curl = curl_init('https://nombre.is/stream.php?mid=.$_GET['id']');)
If I try to do it, it's contradictory to the page file.
<?php
$curl = curl_init('https://nombre.is/stream.php?mid=.$_GET['id'];');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$page = curl_exec($curl);
if(curl_errno($curl)) // check for execution errors
{
echo 'Scraper error: ' . curl_error($curl);
exit;
}
curl_close($curl);
?>
Has anyone an idea on how to fix this?
Upvotes: 0
Views: 1454
Reputation: 1891
i am assuming you want to use id value from $_GET into string URL ?
$id = $_GET['id'];
$curl = curl_init("https://nombre.is/stream.php?mid=$id");
OR
$curl = curl_init("https://nombre.is/stream.php?mid=" . $_GET['id']);
both will work
an other example as per your comment
$page_url = curPageURL();
$curl = curl_init('nombre.is/' . $page_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$page = curl_exec($curl);
or
$curl = curl_init('nombre.is/' . curPageURL());
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$page = curl_exec($curl);
Upvotes: 0
Reputation: 110
There's two ways of doing this! You can either use { }
around the $_GET
variable, which you should use when trying to pull a value from an array into a string, or you can use the concatenation operator .
to join the two values together and append the $_GET['id']
to the end of the URL string.
Option 1:
$curl = curl_init("https://nombre.is/stream.php?mid=${_GET['id']});
Or using the .
operator:
$curl = curl_init("https://nombre.is/stream.php?mid=" . $_GET['id']);
Upvotes: 0
Reputation: 151
You should use string concatenation with the dot . operator, like so.
$curl = curl_init('https://nombre.is/stream.php?mid=' . $_GET['id']);
Upvotes: 1