function Utils::quoteLiteralString
This function converts a string to a quoted javascript string
Parameters
string $str String to quote:
string $quote Quote character:
Return value
string
2 calls to Utils::quoteLiteralString()
- StringLiteral::setFormat in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Node/ StringLiteral.php - Sets string format
- TemplateElement::setValue in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Node/ TemplateElement.php - Sets node's value
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Utils.php, line 214
Class
- Utils
- Utilities class.
Namespace
Peast\SyntaxCode
public static function quoteLiteralString($str, $quote) {
$escape = self::getLineTerminators();
$escape[] = $quote;
$escape[] = "\\\\";
$reg = "/(" . implode("|", $escape) . ")/";
$str = preg_replace($reg, "\\\\\$1", $str);
return $quote . $str . $quote;
}