<?php $userInput = "<script>alert('XSS')</script>"; safeOutput = htmlspecialchars(userInput); echo $safeOutput; // будет выведено <script>alert('XSS')</script> ?>
<?php $pdo = new PDO('mysql:host=localhost;dbname=test', 'user', 'password'); $userInput = "O'Neil"; stmt = pdo->prepare("SELECT * FROM users WHERE username = :username"); stmt->bindParam(':username', userInput); $stmt->execute(); results = stmt->fetchAll(PDO::FETCH_ASSOC); print_r($results); ?>