PHP Salt


A little dash of PHP... my collection of php functions

Version: 2.33.2
Last Build: December 29, 2023 20:28pm (PST)

Main Menu

Home

Get PHP Salt


The Functions

array
db
file
graph
html
mail
math
misc
mobile
script
string
system
time
web
psPrintIf()
Print If


Description:

Prints a string if a var is not empty, also allows a place holder for said str if needed.
Note: there is a trim() on the string



Usage:

psPrintIf($var, [$str]);
if $str no provided, it will print the $var



Example:

	$var = "Mike";
psPrintIf($var, "Hi __VAR__ "); // output: Hi Mike
psPrintIf($var, "Hi Michael"); // output Hi Michael


$var = "";
psPrintIf($var, "Hello World"); // no output





Code:

function psPrintIf($var, $str="__VAR__")
{
$var = trim($var);
if ($var != "") {
$str = str_replace("__VAR__", $var, $str);
print $str;
}
}

Changlelog:


See Also

And a shot out to:

PHP - php.net
Fedora Server - getfedora.com
Shameless ads to pay for site