How can backticks be used to handle special characters, such as hyphens, in SQL queries in PHP?

Special characters, such as hyphens, can cause syntax errors in SQL queries in PHP. To handle these special characters, backticks can be used to enclose column names or table names in SQL queries. This ensures that the special characters are treated as part of the identifier and not as part of the SQL syntax.

$columnName = 'column-name-with-hyphen';
$query = "SELECT * FROM `table-name` WHERE `{$columnName}` = 'value'";
$result = mysqli_query($connection, $query);