Jump to content

Infected.Shadow

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Everything posted by Infected.Shadow

  1. It's a string operator used to concatenate strings. http://php.net/manual/en/language.operators.string.php
  2. In the edit form leave out parseBBCode. Problem solved... Oops, my skim reading led me to believe you were storing it in the database after you parsed it. Carry on. Haha, nope. Just rendering.
  3. While handy, that's going to take significantly more space to store. Takes more space in the database yes, but usually that's never going to be a big issue. Though a better way might be store the original text in the database then implement some sort of caching system to store the rendered text that way you just take out the time of querying the database if there are no new posts. In the edit form leave out parseBBCode. Problem solved...
  4. Yeah I ended up finding an example in the comments of highlight_string on the php manual. As for the other point: That's something I never even thought of, so thank you for that idea. I'd been encoding it as I stored it because I figured that was more secure at the time (which I recall was about 4am when the caffeine was wearing off )
  5. I'm attempting to add syntax highlighting to my bbcode function. I started with the general basis for a bbcode function that there are a million tutorials on. To make things simpler I took out the rest of the bbcode tags. <?php //Eventually will need to add some logic to color the code tags function parseBBCode($string) { $search = array( '/\[code\](.*?)\[\/code\]/is', ); $replace = array( '<div class="code"><code>$1</code></div>' ); //Render the tabs in html //may need to find a better place for this in the future $string = str_replace(' ', ' ', $string); return preg_replace($search, $replace, $string); } ?> I've tried using the highlight_string() function but it never highlights it. I assumed this was because when I store the data in the database I used htmlentities() on the text. So I also tried the following to no avail: '<div class="code">'.highlight_string(html_entity_decode('$1'), true).'</div>' And this where I'm calling the function: $posts = ''; while($post = $db->fetchArray($content)) { $posts .= '<span style="font-size: 22px;">'.$post['title'].'</span><br /> <hr />'; $posts .= '<br />'.nl2br(stripslashes(parseBBCode($post['post']))).'<br /><br /><hr />'; $user = $db->query('SELECT username FROM isnet_users WHERE id = '.$post['poster_id'].';'); $user = $db->fetchArray($user); $posts .= '<strong>Author: </strong>'.$user['username'].'<br /><br />'; } //end while I've tried a few other methods that have produced syntax highlighting but have broken other posts that don't need it. So is there something I'm just obliviously missing?
  6. It's a tad hard to understand what you are trying to accomplish. Perhaps posting the code you've been working with could help make it clearer what you are trying to accomplish. From what I can gather: It sounds like you're trying to reduce the amount of html used in the php file, and some one suggested you use a class. They might have been referring to a template class. If that is the case then I personally suggest following tutorial: http://www.pixel2life.com/publish/tutorials/457/simple_template_engine_find_and_replace_variables/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.