PHP code example of peterujah / php-functions

1. Go to this page and download the library: Download peterujah/php-functions library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

peterujah / php-functions example snippets

 
use \Peterujah\NanoBlock\Functions;
$func = new Functions();

class MyFunction extends \Peterujah\NanoBlock\Functions{
  public function __construct(){
  }
  public function myFunction(){
    //do anything
  }
  public static function myStaticFunction(){
    //do anything
  }
}

$func = new MyFunction();
 
Functions::Random(10, Functions::INT);
 
Functions::timeSocial(php_timestamp);
 
Functions::uuid();
 
Functions::is_uuid($uuid);
 
Functions::is_email($email);
 
Functions::Encrypt($password);
 
Functions::Decrypt($password, $hash);
 
Functions::strongPassword($password, $minLength = 8,$maxLength = 16, $complexity=4);

Functions::removeSubdomain("subdomain.example.com"); //returns example.com
 
Functions::calcAverageRating($total_user_reviews, $total_rating_count);
 
Functions::Money($number, $fractional);
 
Functions::Discount(100, 10); // return 90
 
Functions::Interest(100, 10); //return 110
 
Functions::Fixed(12345.728836, 2);
 
Functions::BigInteger(12345, 728836);
 
Functions::badges(
    ["php", "js", "css"], 
    $bootstrap_color_without_prefix, 
    $type_of_badge, 
    $url_prefix_for_links
);
 
Functions::buttonBadges(
    ["php", "js", "css"], 
    $bootstrap_color_without_prefix, 
    $truncate, 
    $truncate_limit, 
    $selected_button_by_value
);
 
Functions::IP();
 
Functions::hoursRange();
 
Functions::XSS("Rhd53883773", "int");
 
Functions::htmlentities($string, $encode);
 
Functions::UPC($prefix = 0, $length = 12);
 
Functions::EAN($country = 615, $length = 13);
 
Functions::copyFiles("path/from/file/", "path/to/file/");
 
Functions::download(
    "path/to/download/file.zip", //string filepath to download
    "file.zip", // string file name to download
    false // bool delete file after download is complete true or false
);
 
Functions::truncate(
    $text, //string text to truncate
    $length // int length to display
);
 
Functions::base64_url_encode($input);
 
Functions::base64_url_decode($encoded_input);
 
Functions::maskEmail(
    $email, // string email address
    "*" // character to mask with
);
 
Functions::mask(
    $string, // string to mask
    "#", // character to mask with
    $position  //string position to mask left|right|center"
)

Functions::strongPassword($password, $minLength, $maxLength);
 
Functions::remove(
    "path/to/delete/file/", // path to delete files
    false // delete base file once sub files and folders has been deleted
) 
 
Functions::writeLog(
    "path/to/logs/", // string path to save logs
    "info.php",  // string log file name, use .php extension to secure log file from accessible in browser
    $data, // mixed log content
    $secure, // bool set true if file is using .php extension security method 
    $serialize, // bool serialize log content
    $replace // bool replace old log content
);
 
Functions::saveLog(
    "path/to/logs/", // string path to save logs
    "info.php",  // string log file name, use .php extension to secure log file from accessible in browser
    $data, // mixed log content
    $secure, // bool set true if file is using .php extension security method 
    $serialize, // bool serialize log content
);
 
Functions::findLog(
    "path/to/logs/info.php", //string filepath to log
    $unserialize // bool unserialize content if it was saved in serialize mode
);
 
$func->stripeText(
    $string, // string text to stripe unwanted characters
    $rules, // array rules array("[br/]" =>  "&#13;&#10;","<script>"    => "oops!",)
    $textarea // bool display text inside textarea
);