Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Safe Echoing of Query String Parameters</title>
- </head>
- <body>
- City: <?php safe_echo('city', 'your hometown') ?>
- </body>
- </html>
- <?php
- /**
- * Paste me at the bottom of your page or make a file and require_once()
- *
- * <?php safe_echo('city', 'Your Town'); ?>
- *
- * @param $param
- * @param string $default
- */
- function safe_echo($param, $default = '')
- {
- $value = $default;
- if (!empty($_REQUEST[$param]))
- $value = htmlspecialchars($_REQUEST[$param]);
- echo $value;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement