Automatically exported from code.google.com/p/planningalerts
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

shared.escape_special_chars.php 774 B

18 yıl önce
12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Smarty shared plugin
  4. * @package Smarty
  5. * @subpackage plugins
  6. */
  7. /**
  8. * escape_special_chars common function
  9. *
  10. * Function: smarty_function_escape_special_chars<br>
  11. * Purpose: used by other smarty functions to escape
  12. * special chars except for already escaped ones
  13. * @author Monte Ohrt <monte at ohrt dot com>
  14. * @param string
  15. * @return string
  16. */
  17. function smarty_function_escape_special_chars($string)
  18. {
  19. if(!is_array($string)) {
  20. $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
  21. $string = htmlspecialchars($string);
  22. $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);
  23. }
  24. return $string;
  25. }
  26. /* vim: set expandtab: */
  27. ?>