Skip to content

planetoid/php-f-string-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PHP function like Python's f-string function

PHP fprint function like Python's f-strings function

Usage

require_once __DIR__ . '/fprint.php';

$fruit = "apple";
$prize = 123.45;
$input = 'Price of {fruit} yesterday is $ {prize}';
echo fprint($input) . PHP_EOL;
// expected result: Price of apple yesterday is $ 123.45

$boolean_value = true;
$input = "Is today a sunny day? {boolean_value}";
echo fprint($input) . PHP_EOL;
// expected result: Is today a sunny day? TRUE

$null_value = NULL;
$input = "My wallet is {null_value}";
echo fprint($input) . PHP_EOL;
// expected result: My wallet is NULL

$array_value = [""];
$input = "My book list is {array_value}";
echo fprint($input) . PHP_EOL;
/* expected result:
My book list is Array
(
    [0] => 
)
*/

About

PHP string function like Python's f-string function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages