简体   繁体   中英

Php query from url

I'm sure this has been answered on stack before but I don't know the proper terms to use to find my desired results.

I want to take a value in a url and input it into my php script. So if I goto:

http://mydomain/search.php='MYSEARCHQUERY'

The search.php would take the MYSEARCHQUERY as a value.

<?php 
$html=file_get_contents('http://anotherwebsite/MYSEARCHQUERY'); 
?>

The URL would be something like:

http://mydomain/search.php?query=MYSEARCHQUERY

and the PHP:

$html = file_get_contents('http://anotherwebsite/' . $_GET['query']); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM