Jump to content


[CODE]


8 replies to this topic

#1 ericrcan

    Young Padawan

  • Members
  • Pip
  • 103 posts

Posted 27 January 2006 - 09:24 PM

Ok, it accured to me, that I dont know what im talking about :blush: .. I wanted to set up a [ code] llike the forum, but it wouldnt work..I couldnt put html or php in the tags..I was fiddling around, but it still didnt work..So, what exactly do I need? Not a BBCode parser..A HTML parser? PHP parser? I want it like the ones I see the tutorials use..I need it so I can put CSS, Javascript, PHP, and HTML into it..Anyone know what I need? Thanks.

#2 ericrcan

    Young Padawan

  • Members
  • Pip
  • 103 posts

Posted 27 January 2006 - 09:28 PM

omg..im a freakin idiot..i forgot that i solved it lol...what i need now, is i wanted to know about php highlight...

Edited by zYpher, 27 January 2006 - 09:33 PM.


#3 coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 27 January 2006 - 10:14 PM

well.. php highlight is easy..

<?
highlight_string('
<?
   $is = "is";
   echo "this php code" . $is . "highlighted";
?>');
?>
if your using php 5 with highlight_string is should also highlight html
: )

***** edit *****
hmm.. i just checked the function
http://us2.php.net/m...ight-string.php
i dont know where i got that it highlights html..

Edited by coolaid, 27 January 2006 - 10:33 PM.


#4 ericrcan

    Young Padawan

  • Members
  • Pip
  • 103 posts

Posted 28 January 2006 - 01:30 AM

omg..i love you! lol..i wanted it to highlight, and i got that, plus i didnt hvae to edit teh code so it didnt count as a function..thank you! (i know nothing about php lol).. !!! HOOAH!


*edit*
is there a way to keep the formatting? also, i ahve it in a div, but if i have 1 big line, it will just continue on past the div..how do i keep it in? (i know thats css)...

Edited by zYpher, 28 January 2006 - 01:41 AM.


#5 coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 28 January 2006 - 02:12 AM

simple

<div>
<pre>
<code>
<? php code ?>
</code>
</pre></div>

that should work

#6 ericrcan

    Young Padawan

  • Members
  • Pip
  • 103 posts

Posted 28 January 2006 - 11:04 AM

yea, it didnt..i have:

<div id="code-container">
				<div id="code-top">&nbsp;</div>
				<div id="code-main"><?
	highlight_string('<?php this php .is. highlighted ?>');
	?>			</div>
</div>


the test url is http://www.kreatived...ks.net/main.php

Edited by zYpher, 28 January 2006 - 11:26 AM.


#7 ericrcan

    Young Padawan

  • Members
  • Pip
  • 103 posts

Posted 28 January 2006 - 11:40 AM

ok..well..its the highlight function thats messing up the way the text is..i took off the php functnion, and it worked fine..i put in the highlight, then it was just 1 long text strand..anyone know how to fix?? ill look...


*EDIT*

ok i got it to work! 1 problem..there is a "1" at teh end of the function...i used this function:

<?php
$text = 'text goes here......';
$newtext = wordwrap($text, 55, "\n");

echo highlight_string($newtext);
?>

the problem is, that it returns a 1 at the end on the website..is there anyway to bypass that?

Edited by zYpher, 28 January 2006 - 12:12 PM.


#8 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 28 January 2006 - 01:25 PM

php.net said:

If the second parameter return is set to TRUE then highlight_string() will return the highlighted code as a string instead of printing it out.
Note: The return parameter became available in PHP 4.2.0. Before this time it behaved like the default, which is FALSE
<?php
$text = 'text goes here......';
$newtext = wordwrap($text, 55, "\n");

highlight_string($newtext);
?>
Also, the highlight_string function will keep the formatting of your code automatically. If you look at any of the php tutorials on my site (more specifically this one), they all use highlight_string('<? the code ?>'), and no formatting is lost. So there might be some other problem with your code if it's not keeping the formatting.

Edited by rc69, 28 January 2006 - 01:35 PM.


#9 ericrcan

    Young Padawan

  • Members
  • Pip
  • 103 posts

Posted 28 January 2006 - 03:09 PM

thank you soo much! i love you guys :D





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users