Jump to content
php.lv forumi

BB koda mistika?


chizijs

Recommended Posts

Kods

       $teksts = htmlspecialchars($at_t['teksts']);
       $get = array(
"/\[code](.*?)\[\/code\]/isU"
       );
       $replace = array(
"<div class='codetop'>KODS</div><div class='codemain'>$1</div>"
       );
       $teksts = preg_replace($get,$replace,$teksts);
       echo nl2br($teksts);

Bet kad izvāda tekstu

[.code]

<?

echo "";

function ddd (){

if(){}

}[./code]

iznāk

<?

echo "";

/> function ddd (){

/> if(){}

}

Kaut kāds mistisks simbols parādas />, ja pat viņš nekur nav pieminēts??

Edited by chizijs
Link to comment
Share on other sites

pamēģināju tavu piemēru un nostrādāja diezgan forši. nav nekādu />

varbūt kkas ar encoding. fails nav utf. jo man izskatās ok :)

<?php
$at_t['teksts'] = '
[.code]
<?
echo "";
function ddd (){
if(){}
}[/.code]
';
$teksts = htmlspecialchars($at_t['teksts']);        
$get = array(        "/\[code](.*?)\[\/code\]/isU"        );        
$replace = array(        "<div class='codetop'>KODS</div><div class='codemain'>$1</div>"        );        
$teksts = preg_replace($get,$replace,$teksts);        
echo nl2br($teksts);
?>

Edited by php newbie
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...