SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: Help! highlight_string()
-
Mar 9, 2001, 09:39 #1
- Join Date
- Aug 2000
- Location
- N.S., Canada
- Posts
- 487
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey,
I'm trying to get highlight_string() to work, here's my code:
PHP Code:<form action="<? echo "$PHP_SELF" ?>" method="POST">
<input type="texbox" rows="6" cols="9" name="foo"><input type="submit">
</form>
Results:
<?
htmlspecialchars($foo);
highlight_string($foo);
?>
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in c:\webdocs\hilite.php on line 7
Anyone know whats wrong?
Thanks,
Justin Sampson
-
Mar 9, 2001, 11:43 #2
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Unfortunately highlight_string() needs to have <? ?> tags present in order to work, and it seems that you must replace \ with '' before it will work with that sort of character, I got it to work this way
PHP Code:<form action="<?=$PHP_SELF?>" method="POST">
<input type="texbox" rows="6" cols="9" name="foo"><input name="submit" type="submit" value="submit">
</form>
Results:
<?
if($submit) {
$foo = addslashes($foo);
$foo = htmlspecialchars($foo);
$foo = str_replace('\\', '', $foo);
highlight_string("<? print $foo; ?>");
}
?>Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Mar 9, 2001, 11:49 #3
- Join Date
- Nov 2000
- Location
- Hong Kong
- Posts
- 1,508
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Freddy, I also was trying to do this however there was a problem since the [*PHP] tags in vBulletin remove the \'s.
I think you gotta put in the [*CODE] tags.
Thanx Allot...
-
Mar 9, 2001, 11:50 #4
- Join Date
- Aug 2000
- Location
- N.S., Canada
- Posts
- 487
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok, see, what I'm trying to do is add a [ php ] feature to my forum. I can get everything between the [ php ] and [/ php ] tags into a variable, just can't get the highlight to work.
-
Mar 9, 2001, 11:52 #5
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Justin so just add <? and ?> to each side of the var that holds the stuff betweeen the
PHP Code:and
Please don't PM me with questions.
Use the forums, that is what they are here for.
Bookmarks