Page 1 of 1

custom highlight code

Posted: 22 Dec 2020, 07:06
by JanMolendijk
Hello Coursesweb I try to update my highlight code from ini_set
but I would also like to color it with string replacements or something else

For the moment only <php + ?> is highlighted +
info code with // enter text is highlighted

The code aply from a text-file into the document.

Code: Select all

<?php
	$res = $MySQLiconn->query("SELECT * FROM `userfiles` where code_id='$id' ORDER BY `ID` DESC  ");
	$count = $res->num_rows;

	if($count > 0)
	{
		while($row=$res->fetch_array())
		{
			?>

Code: Select all

<?php
ini_set("highlight.comment", "#008000");
ini_set("highlight.default", "#000000");
ini_set("highlight.html", "#808080; font-size: 16px;");
ini_set("highlight.keyword", "#0000BB; font-weight: bold");
ini_set("highlight.string", "#DD0000");
?>
I would like in the output an complete highlighted file as result now it only one part.

Code: Select all

<?php show_source("$row[FilePath]/Files--PHP-HTML-CODE/$row[code_file]/$row[FileName]"); ?>
Here is an example from the result (Only the php code in result is highlighted).
145.53.93.209/Molendijk/Source/upload/Show/Maps/source.php?id=530835

custom highlight code

Posted: 22 Dec 2020, 10:25
by MarPlo
Try with the php highlight_string() function.
More details and examples to the php documentation: highlight_string

custom highlight code

Posted: 22 Dec 2020, 10:54
by JanMolendijk
I found the answer Thanks for suporting

Code: Select all

<h1 style="font-size:20;">
<?php

 ini_set('highlight.html', '"font-size="20px "class="aw_htmlsrc');
 
 $aw_source = highlight_file("$row[FilePath]/Files--PHP-HTML-CODE/$row[code_file]/$row[FileName]", TRUE);
 echo str_replace("", "" , $aw_source );
 ?>
</h1>