• šŸŒ™ Community Spirit

    Ramadan Mubarak! To honor this month, Crax has paused NSFW categories. Wishing you peace and growth!

3 Useful PHP Custom Functions That Every Developer Should Know (1 Viewer)

Currently reading:
 3 Useful PHP Custom Functions That Every Developer Should Know (1 Viewer)

Recently searched:

james125

Member
LV
3
Joined
Nov 30, 2022
Threads
19
Likes
49
Awards
7
Credits
20,452Ā©
Cash
1$
The following three custom functions can be used in PHP applications to help make development easier and faster.


PHP:
<?php
// Returns TRUE if the given string is a valid URL
function isValidUrl($url) {
  return filter_var($url, FILTER_VALIDATE_URL);
}

// Encrypts a string using a given key
function encryptString($string, $key) {
  return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_ECB));
}

// Decrypts a string using a given key
function decryptString($string, $key) {
  return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($string), MCRYPT_MODE_ECB);
}
?>

That's it! Now you can use these functions to quickly validate URLs, encrypt strings, and decrypt strings. šŸ”
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Tips
Recently searched:

Similar threads

Users who are viewing this thread

Top Bottom