pull-icon
logo-mobile

Random Greeting

Home/Forums/Random Greeting

EmmaS

today at 04:58

Use a .txt based file to retrieve random messages.
Your greeting displays in a centered card-like panel with a light background and drop shadow.

<?php
declare(strict_types=1);

// Load file contents safely
$file = 'flatfile.txt';

if (!file_exists($file)) {
    $randPhrase = "Welcome! (No greetings found)";
} else {
    $lines = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

    if (!$lines) {
        $randPhrase = "Welcome! (Greeting list is empty)";
    } else {
        // More secure random selection
        $randPhrase = $lines[random_int(0, count($lines) - 1)];
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Random Greeting</title>
    <style>
        body {
            font-family: system-ui, sans-serif;
            background: #f7f7fb;
            display: flex;
            height: 100vh;
            align-items: center;
            justify-content: center;
            margin: 0;
        }
        .greeting-box {
            background: white;
            padding: 40px 50px;
            border-radius: 12px;
            box-shadow: 0 8px 20px rgba(0,0,0,0.08);
            font-size: 28px;
            color: #333;
            text-align: center;
        }
    </style>
</head>
<body>

<div class="greeting-box">
    <?= htmlspecialchars($randPhrase, ENT_QUOTES, 'UTF-8'); ?>
</div>

</body>
</html>


Open notepad and add a few lines:
Hello and Welcome!
Hi how are you today?
Hey there, what you doin?

Save as: flatfile.txt

Leave a Comment

You must be logged in to post a reply.


BellOnline provides fast, reliable UK hosting designed for modern radio and web projects. Optimised servers, strong security, and excellent uptime ensure your station runs smoothly.
MixStream delivers broadcast-grade radio streaming with outstanding stability, crystal-clear audio, and powerful performance even during peak listener hours. Perfect for hobby stations and professional broadcasters alike.


Your secure download link has been emailed to:

Goto BellOnline Now!