public _quoteXMLChars ( $string ) : string | ||
return | string | quoted string |
public function _quoteXMLChars($string)
{
$search = array('&', '<', '>', "'", '"');
$replace = array('&', '<', '>', ''', '"');
$string = str_replace($search, $replace, $string);
$string = utf8_encode($string);
return $string;
}
/** * Should convert specials chars, & encode in utf8. */ public function testQuoteXMLChars() { $ops = new Ops(); $data = 'This is my & < > \' " string'; $result = $ops->_quoteXMLChars($data); /// chars should be converted $this->assertEquals($result, 'This is my & < > ' " string'); // should be utf8 $this->assertTrue(mb_check_encoding($result, 'UTF-8')); }