0

How to put the querystring name in php?

$file_get_html('http://localhost/search/?q=');

And when accessing localhost/?name=example the code looks like this

$file_get_html('http://localhost/search/?q=example');

I do not know how to put $_GET['url'] inside a php :(

5
  • file_get_html($_GET['url']); - if that's really what you mean. Commented Jun 20, 2013 at 0:32
  • There's no $ before file_get_html Commented Jun 20, 2013 at 0:32
  • The question isn't very clear. Are you trying to merge the query string you received with some other URL? Commented Jun 20, 2013 at 0:34
  • I am not following what you want. What does a parameter of URL have to do with the parameter q that you are showing? can you better explain what is is you are trying to do? Commented Jun 20, 2013 at 0:35
  • <?php // setup require_once('simple_html_dom.php'); // get DOM from URL or file $html = $file_get_html('http://localhost/serarch/?q='); ?> Wanna use the Simple HTML DOM Parser to extract data of a page. However, this page is a result of seek. So, I replace the variable in my url, the site url [search]. Commented Jun 20, 2013 at 2:18

3 Answers 3

1

The question isn't very clear, but I suspect this is the answer:

file_get_html('http://localhost/search/?q=' . urlencode($_GET['url']));
Sign up to request clarification or add additional context in comments.

5 Comments

Notice: Undefined variable: file_get_html in C:_server\htdocs\test.php on line 7 Fatal error: Function name must be a string in C:_server\htdocs\test.php on line 7 line 7: $html = $file_get_html('http://localhost/bsearch/?q=' . urlencode($_GET['movie']));
Didn't you see the comment I wrote an hour ago? There shouldn't be a $ before file_get_html().
Oh, sorry. Worked. I thought the $ in front of file_get_html was standard for extension
$ is for variables in PHP, I don't know where you got the idea it had anything to do with extensions.
Although I know very little PHP, I know that the $ is all PHP variables. However, I thought it was necessary for the extension to work $. Anyway.
0

The ?q=example will let you use something like $example = $_GET['q'], and $example should equal the value of q in your querystring.

If you have a querystring that looks like this:

?q=example&url=myurl.com

You can access the q and url parameters like this:

$q = $_GET['q']; // which will equal 'example'
$url = $_GET['url']; // which will equal 'myurl.com'

If that is what you are trying to do.

1 Comment

But how to put in $file_get_html?
0
$url = urlencode($_GET['url']);
$contents = file_get_contents("http://localhost/search/?q={$url}");

var_dump($contents);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.