random character generator php function code example

Example 1: randstring php

<?php 
    $random = substr(md5(mt_rand()), 0, 7);
    echo $random;
?>

Example 2: javascript detect right click

el.addEventListener('contextmenu', function(ev) {
    ev.preventDefault();
    alert('success!');
    return false;
}, false);

Example 3: rand string php

function RandomString()
    {
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $randstring = '';
        for ($i = 0; $i < 10; $i++) {
            $randstring = $characters[rand(0, strlen($characters))];
        }
        return $randstring;
    }