Skip to content

matronator/pristine-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pristine PHP

Pristine PHP logo

Collection of useful PHP functions and code snippets.

Advanced string Interpolation

Source: https://stackoverflow.com/a/15410466/13604898

function identity(mixed $arg): mixed {
    return $arg;
}
$interpolate = "identity";

echo "<input value='{$interpolate(1 + 1 * random_int())}' />";

Casting

See Casting.php

Folder exists

/**
 * Checks if a folder exist and return canonicalized absolute pathname (sort version)
 * @param string $folder the path being checked.
 * @return mixed returns the canonicalized absolute pathname on success otherwise FALSE is returned
 */
function folder_exist(string $folder): string|false
{
    // Get canonicalized absolute pathname
    $path = realpath($folder);

    // If it exist, check if it's a directory
    return ($path !== false AND is_dir($path)) ? $path : false;
}

JSON to class

See JSON2Class.php

One time file download

See OnetimeFileDownload.php

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy