How does the use of the LIKE operator in SQL queries impact the security and efficiency of PHP code?

Using the LIKE operator in SQL queries can impact the security and efficiency of PHP code if not properly sanitized. It can make the code vulnerable to SQL injection attacks if user input is not validated. To mitigate this risk, it is important to sanitize user input and use prepared statements when executing SQL queries.

// Sanitize user input before using it in a SQL query with the LIKE operator
$searchTerm = mysqli_real_escape_string($conn, $_POST['searchTerm']);

// Use a prepared statement to safely execute the SQL query
$stmt = $conn->prepare("SELECT * FROM table_name WHERE column_name LIKE ?");
$stmt->bind_param("s", $searchTerm);
$stmt->execute();