method asVar documentation in bbn\Str

Places quotes around a string

Example

var_dump(\bbn\Str::asVar('foo')); // (string) '"foo"' var_dump(\bbn\Str::asVar("foo", "'")); // (string) "'foo'" var_dump(\bbn\Str::asVar("foo'bar")); // (string) '"foo\'bar"' var_dump(\bbn\Str::asVar("foo'bar", "'")); // (string) "'foo\'bar'" function(string $var, $quote = '"') { if (($quote !== "'") && ($quote !== '"')) { $quote = '"'; } $st = $quote === "'" ? self::escapeSquotes($var) : self::escapeDquotes($var); return $quote.$st.$quote; }

Places quotes around a string BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.