display php code by bb function -


have function witch display php code mysql

function bb($message) {   preg_match_all( "#\[php\](.+)\[\/php\]#isu", $message, $matches );   $cnt = count( $matches[0] );    ( $i = 0; $i < $cnt; $i++ ) {     $phpblocks[] = '<span class="quote"><span class="quotename">cod php:</span>'.highlight_string( $matches[1][$i], true ).'</span>';     $uniqidphp = '[php_'.uniqid('').']';     $uniqidsphp[] = $uniqidphp;     $message = str_replace( $matches[0][$i], $uniqidphp, $message );    }    $spaces = array( ' ', "\t" );   $entities = array( '&nbsp;', '&nbsp;&nbsp;&nbsp;&nbsp;' );    preg_match_all( "#\[code\](.+)\[\/code\]#isu", $message, $matches );   $cnt = count( $matches[0] );    ( $i = 0; $i < $cnt; $i++ ) {     $codeblocks[] = '<div class="code">'.nl2br( str_replace( $spaces, $entities, htmlspecialchars( $matches[1][$i] ) ) ).'</div>';     $uniqidcode = '[code_'.uniqid('').']';     $uniqidscode[] = $uniqidcode;     $message = str_replace( $matches[0][$i], $uniqidcode, $message );    }    $message = nl2br( $message);    if ( isset( $uniqidcode ) ) $message = str_replace( $uniqidscode, $codeblocks, $message );   if ( isset( $uniqidphp ) ) $message = str_replace( $uniqidsphp, $phpblocks, $message );    return $message; } 

the ex message mysql

hello [php]<?php echo "hello"; ?>[/php]

goodbye [php]<?php echo "goodbye"; ?>[/php]

see [php]<?php echo "see soon"; ?>[/php]

the problem every time refresh page showing 1 , same code

ex:

hello <?php echo "hello"; ?>

goodbye <?php echo "hello"; ?>

see <?php echo "hello"; ?>

or

hello <?php echo "goodbye"; ?>

goodbye <?php echo "goodbye"; ?>

see <?php echo "goodbye"; ?>

how fix ?


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -