PHP Code Snippets

Server-side scripting snippets with PHP.

<?php

// your code goes here
function generatePassword($length = 12) {
    return bin2hex(random_bytes($length / 2));
}

 const password = generatePassword();

Generate a secure random password in php

This function generates a cryptographica...
<?php

function capitalizeFirstLetter($string) {
    return ucfirst(strtolower($string));
}

echo capitalizeFirstLetter("mahbub");  // Mahbub

Capitalize First Letter in PHP

Change the passed parameter "mahbub" wit...