PayPal\Core\PPUtils::escapeInvalidXmlCharsRegex PHP Метод

escapeInvalidXmlCharsRegex() публичный статический Метод

Escapes invalid xml characters
public static escapeInvalidXmlCharsRegex ( $textContent ) : string
$textContent = xml data to be escaped
Результат string
    public static function escapeInvalidXmlCharsRegex($textContent)
    {
        return htmlspecialchars($textContent, 1 | 2, 'UTF-8', false);
    }

Usage Example

Пример #1
0
 /**
  * @param string $property
  * @param PPXmlMessage|string $value
  * @param string $namespace
  * @return string
  */
 private function buildProperty($property, $value, $namespace = 'ebl')
 {
     $annotations = PPUtils::propertyAnnotations($this, $property);
     if (!empty($annotations['namespace'])) {
         $namespace = $annotations['namespace'];
     }
     if (!empty($annotations['name'])) {
         $property = $annotations['name'];
     }
     if ($namespace === true) {
         $el = '<' . $property;
     } else {
         $el = '<' . $namespace . ':' . $property;
     }
     if (!is_object($value)) {
         $el .= '>' . PPUtils::escapeInvalidXmlCharsRegex($value);
     } else {
         if (substr($value = $value->toXMLString(), 0, 1) === '<' || $value == '') {
             $el .= '>' . $value;
         } else {
             $el .= ' ' . $value;
         }
     }
     if ($namespace === true) {
         return $el . '</' . $property . '>';
     } else {
         return $el . '</' . $namespace . ':' . $property . '>';
     }
 }