<?php
$file = __DIR__ . '/index.php';
$txt = file_get_contents($file);

$start = strpos($txt, '<!-- -- FOOTER -- -->');
$end   = strpos($txt, '</footer>') + strlen('</footer>');

echo "start=$start end=$end len=" . strlen($txt) . "\n";

if ($start !== false && $end > $start) {
    $txt = substr($txt, 0, $start) . "<?php include 'footer.php'; ?>" . substr($txt, $end);
    file_put_contents($file, $txt);
    echo "Done. New len=" . strlen($txt) . "\n";
} else {
    echo "NOT FOUND\n";
}
