← CodePrimer
PHP
Beginner
Forms
Read $_GET values
How do I read query string data?
$_GET superglobal.
<?php
$q = trim((string) ($_GET['q'] ?? ''));
echo htmlspecialchars($q, ENT_QUOTES, 'UTF-8');
Notes
Best for search/filters. Never trust raw input.
Keywords: $_GET · query · get · form
Related
PHP
Embed PHP inside HTML
How do I mix PHP and HTML?
PHP
PHP comments
How do I write comments in PHP?
PHP
PHP variable rules
What are the rules for PHP variables?
PHP
echo vs print
Should I use echo or print?
PHP
PHP scalar data types
What data types does PHP have?
JavaScript
Live input event
How do I react as the user types?