1

Тема: Вставка html кода в php и экранирование символов

Очень раздражает, что когда надо вставить какой-то html код в php, то надо что то экранировать...
К примеру, хочу вставить счетчик лайвинтернета на страничку, а шаблон сайта на php.
Вот и приходится вместо кода:
<!--LiveInternet counter--><script type="text/javascript"><!--
document.write("<a href='http://_.liveinternet.ru/click' "+
"target=_blank><img src='//counter.yadro.ru/hit?t26.11;r"+
escape(document.referrer)+((typeof(screen)=="undefined")?"":
";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?
screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+
";"+Math.random()+
"' alt='' title='LiveInternet: показано число посетителей за"+
" сегодня' "+
"border='0' width='88' height='15'><\/a>")
//--></script><!--/LiveInternet-->


Вставлять

<!--LiveInternet counter--><script type="text/javascript"><!--
document.write("<a href=\'http://_.liveinternet.ru/click\' "+
"target=_blank><img src=\'//counter.yadro.ru/hit?t26.11;r"+
escape(document.referrer)+((typeof(screen)=="undefined")?"":
";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?
screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+
";"+Math.random()+
"\' alt=\'\' title=\'LiveInternet: показано число посетителей за"+
" сегодня\' "+
"border=\'0\' width=\'88\' height=\'15\'><\/a>")
//--></script><!--/LiveInternet-->

В принципе можно сделать везде замену с ' на \'
Но все рано раздражает, хоть и надо.

Поделиться