You are here

public function Escaper::escapeCss in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-escaper/src/Escaper.php \Zend\Escaper\Escaper::escapeCss()

Escape a string for the CSS context. CSS escaping can be applied to any string being inserted into CSS and escapes everything except alphanumerics.

Parameters

string $string:

Return value

string

File

vendor/zendframework/zend-escaper/src/Escaper.php, line 213

Class

Escaper
Context specific methods for use in secure output escaping

Namespace

Zend\Escaper

Code

public function escapeCss($string) {
  $string = $this
    ->toUtf8($string);
  if ($string === '' || ctype_digit($string)) {
    return $string;
  }
  $result = preg_replace_callback('/[^a-z0-9]/iSu', $this->cssMatcher, $string);
  return $this
    ->fromUtf8($result);
}