Jump to content


PHP highlight

  • Please log in to reply
3 replies to this topic

#1 Jezdo

  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 September 2006 - 07:46 PM

Hi everyone. I have next BBCode:
         $PHPCodeLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" background="images/code.jpg">
                                    <td><span class="quotecodeheader style1">PHP kod: </span></td>
                                    <td background="images/code.jpg">'.
									highlight_string(stripslashes('$1'), true).'</td>
            // Check for [code=php:0] text
            $Text = preg_replace("/\[php\](.+?)\[\/php\]/is","$PHPCodeLayout", $Text);
So, what is the problem?
It doesn't highlight the sintax. :(
Please, can you help me? I searched for help everywhere but I didn't find it - you are my last hope.

#2 AndyB

  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 02 September 2006 - 09:08 PM

Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

If the highlight is supposed to appy to a string that appears to start with a number ...

The link you cite leads to a page that's in a language I can't understand.

Also, do NOT send PMs to moderators claiming an 'urgent' need for help.
Legend has it that reading the manual never killed anyone.
My site

#3 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 September 2006 - 10:07 PM

I find it easier to use a function called preg_replace_callback when doing this sort of thing. Have a read of this post of mine for an example.

What you do is create a dedicated function which will be called by preg_replace_callback when a match is found.

#4 Demonic

  • Members
  • PipPipPip
  • Advanced Member
  • 562 posts

Posted 02 September 2006 - 10:15 PM

i gave up on that php tags :(

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users