So I want to have dynamic text depending on the url. For example if the url is: www.mysite.com/index.php?variable=test I then want to have a page with a paragraph of text that has a variable. So everytime the website has $variable in the text, it replaces the $variable with test or whatever I specify in the URL. How do I do this and what is it called? I tried searching google for dynamic php text but I didnt find anything on how to actually do it. Thanks,
<?php // www.mysite.com/index.php?variable=test if (array_key_exists('variable', $_GET)) { $variable = $_GET['variable']; } ?> <!-- your paragraph --> blah blah blah blah <?php echo $variable; ?> or blah blah blah blah <?=$variable?> PHP:
Or you could do something like (1 line code): <? if (isset($_GET['variable']) echo $_GET['variable']; // You may want to sanitize this var as it can lead to security holes. ?> PHP: