How can a counter be scripted to appear only in the source code or elsewhere, not on the site itself?

To have a counter appear only in the source code or elsewhere, not on the site itself, you can store the counter value in a PHP session variable. This way, the counter will be incremented in the background without displaying it on the site. You can then retrieve and display the counter value in the source code or any other desired location.

<?php
session_start();

if (!isset($_SESSION['counter'])) {
    $_SESSION['counter'] = 1;
} else {
    $_SESSION['counter']++;
}

// Display the counter value in the source code or elsewhere
echo "Counter: " . $_SESSION['counter'];
?>