How can PHP be used to secretly notify a website owner via email when someone visits their site?

To secretly notify a website owner via email when someone visits their site, you can add a PHP script at the top of the website's main file (e.g., index.php) that sends an email notification using the mail() function. This script should be triggered whenever the page is accessed, allowing the website owner to be notified of each visit.

<?php
$to = 'websiteowner@example.com';
$subject = 'New visitor notification';
$message = 'Someone has visited your website.';
$headers = 'From: notification@example.com';

// Send email notification
mail($to, $subject, $message, $headers);
?>