-7

This would be an example:

<a href="http://mywebsite.com/redirect.php&q=dynamic_word">redirect</a>

dynamic_word can be changed because it is dynamic. When click "redirect", dynamic_word will be extracted. So, how to extract it in redirect.php file ? Thanks !

user3571494
  • 167
  • 1
  • 8

2 Answers2

0

Use $_GET to get parameters from an URL

   <?php

    $thatName = $_GET['q'];

    echo $thatName;

Result

dynamic_word
underscore
  • 6,495
  • 6
  • 39
  • 78
0

If samitha's correct looking answer is incorrect then perhaps you mean you would like to extract the dynamic word from a string.

In that case you could do

<?php

$string = 'http://mywebsite.com/redirect.php&q=dynamic_word';

$ex_stirng = explode('&q=', $string);

$dynamic_word = $ex_string(1);

?>

Or even use the strstr function: http://www.php.net/manual/en/function.strstr.php

Friendly Code
  • 1,585
  • 1
  • 25
  • 41
  • Thanks, http://mywebsite.com/redirect.php&q=dynamic_word is address URL. Can you show me how to get it, please ? – user3571494 Apr 26 '14 at 15:58
  • You have been given three solutions. Unless you explain what you are trying to do in more detail I don't think you're going to receive any more help :-S – Friendly Code Apr 26 '14 at 16:02