Jump to content

hightlighting a string quistion and example


redarrow

Recommended Posts

advance thank you......

 

I am in the process off creting a forum and i want to show raw php code syntex....

 

I have got this far using the highlight_string function().......

 

is there any other function to show code off to pearing eyes cheers......

 

<?php

$code='<?php

//$number varable is set to 1.

$number=1; 

//$number varable is now incremented by 1 using the ++ sign.

$number++;

// result of number is 2 becouse we add 1 by the ++ sign called increment.

echo $number; 

//please copy and paste the code to see the results....

?>';

if (eregi("^(\<\?php|\<\?)",$code)){

highlight_string($code);

echo $code;

}else{

echo 'Sorry your php opening tag has to be in order of <? or this <?php';

exit;
}
?>

<p></p>

<?php $number=1; $number++; echo "the result off \$number is: $number"; ?>


 

 

From what I can grasp, you want another function to color-code your PHP syntax?  There are plenty out there, but may I ask why highlight_string isn't working out for you?  Are you looking for support for other coding languages, or do you want to change the colors of the syntax?  (Syntax colors can be set through php.ini), such as:

 

ini_set ('highlight.string',  '#000000');

ini_set ('highlight.comment', '#FF8000');

ini_set ('highlight.keyword', '#00FF00');

ini_set ('highlight.bg',      '#CCCCCC');

ini_set ('highlight.default', '#DDDDDD');

ini_set ('highlight.html',    '#EEEEEE');

can you exsplain the concept off the colors and there acting function

 

example

 

ini_set ('highlight.string',  '#000000'); <<< what they relate to why the joiing .
ini_set ('highlight.comment', '#FF8000');<< what the funtion highlight.comment do and others cheers.....
ini_set ('highlight.keyword', '#00FF00');
ini_set ('highlight.bg',      '#CCCCCC');
ini_set ('highlight.default', '#DDDDDD');
ini_set ('highlight.html',    '#EEEEEE');

 

is this css but using the function highlight string()

 

sorrry but i really like to no all for future refrence cheers regards redarrow....

i uderstand php very well, i am learning new functions as i go on, so i need to no what

the highlight.string,highlight.keyword ect ect relate to for showing purpose....

 

i understand the color is passed to the highlight_string() function but in relation to the colors what do they change for example hightlight.html does that mean all html is that color now...

 

sorry i am currently in a internet cafe, So i am blind to see my own examples.....

example

 

what the rest do as there not showing.......

 

ini_set ('highlight.string',  'brown');
ini_set ('highlight.comment', 'gray');//-------- highlights all php comments
ini_set ('highlight.keyword', 'pink');//-------highlights any php charecters and operaters
ini_set ('highlight.bg',      'yellow');
ini_set ('highlight.default', 'blue');//-------- hightlights all php varables
ini_set ('highlight.html',    'red');

What i was trying to do is enter text and php code, when it finds the code charecters

it hightlights the code to bee shown to browser.....

 

<?php

//database connection

if($_POST['submit']){

$x=$_POST['x'];

$m=htmlspecialchar($x); 

$sqla="insert into(id,m)VALUES('$id','$m')";

$resulta=mysql_query($sqla) or die(mysql_error());

echo" <br> Thank you database entry entered <br> ";

$sqlb="select * from test";

$resultb=mysql_query($sqlb) or die(mysql_error());

while($k=mysql_fetch_assoc($resultb)){

$resultc=mysql_query($sqlc) or die(mysql_error());

if(eregi("(\[\code\])*(\[\\code])",$k['x'])){

	heightlight_string($k['x']);
}
     }
      }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.