English
00:00:00


The script for the highlighting of program code

The slider script  |  Zip unpacker  |  The script hit counter  |  Feedback script  |  Click to enlarge

AVL advertising materials rotator  |  How much is currently on the site.  |  Online program code highlighting

The script for the highlighting of program code  |  Form for uploading multiple images

Two examples of form code for uploading multiple images  |  Php handler for uploading multiple images to the server

Your comment or question

Скрипт для подсветки программного кода

The script for highlighting program code is written in PHP and is intended initially for it.
But the design of software languages is similar to each other.
This is why the script perfectly highlights javascript and similar languages.
Even HTML highlights perfectly, although structurally it is not at all similar to PHP
That's just CSS highlights so-so, the property and its value are not always
differ in color.

The "highlight_string" function that the script is based on highlights the code
different color only after the PHP opening tag. Before tag or without tag code
by default, all is black. And for other languages, use the PHP tag
it's ridiculous.

But this feature of the function can be circumvented. Some programmers offer
use output buffering. I decided to go the other way.

First check whether there is a tag or not, if there is one, delete it.
I have it replaced with a comment / / php.

I also replace the javascript tag with a comment / / javascript.
Since the closing javascript tag (s) also returns black.

Then it is processed by the "trim" function, so that there are no surprises.
Then the script inserts the tag itself, so that the code is colored, and returns
a string of the "highlight_string" function to process.

After processing, the function deletes the conversion from the PHP tag.
It remains to display the page and the color code is ready!

Showing examples of highlighting languages: HTML, CSS, PHP, javascript.
in the PHP example, the script code itself.

// javascript

function bigimg(imgname) { 
var 
imggross '<div id="skrinbig" style=" display: block; position: absolute;
 top: 100px; left: 200px; width: 1200px; height:auto; background: rgba(0, 0, 0, .8);
  z-index: 100; border:1px solid #0002ff; -moz-border-radius: 7px; -khtml-border-radius: 7px;
   -webkit-border-radius: 7px; border-radius: 7px; list-style-type: none;">
  <p style=" display:block; position: relative; left: -10px;" align="right">
  <a href="#" onclick=" bigclose();">
  <img alt="закрыть" title="закрыть" src="/images/cross.png">
  </a></p><p align="center" id="skrinimg">
  <img alt="скриншот" title="скриншот" src="/images/' 
imgname '"></p></div>';
document.getElementById("imgbig").innerHTML+=imggross;
}

function 
bigclose() {
var 
imgclos "";
document.getElementById("skrinbig").outerHTMLimgclos;   
}


// HTML
<a href="#" onclick=" var imgname; bigimg('bigimg.png');">
<
img width="265px" alt="Нажми чтобы увеличить" title="Нажми чтобы увеличить" src="/images/bigimg.png"></a>

// CSS
.subm {
   
displayinline;
   
width120px;
   
height25px;
   
backgroundurl("/images/button_9.png");
   
border:0;
   
border-radius:8px;
   -
moz-border-radius:8px;
   -
webkit-border-radius:8px;
   
font-weightbold;
   
font-styleitalic;
   
font-size:12px;
   
text-decorationnone;
   
coloryellow;
   
cursorpointer;
}

// PHP 
$phpcod '< ?php';
$phpcod2 '< ?';
$javascr '< script>';
$javascr2 '< /script>';

if (
stristr($codstring$phpcod) !== false) {
   
$codstring str_ireplace($phpcod"// PHP"$codstring);
  }
if (
stristr($codstring$phpcod2) !== false) {
   
$codstring str_ireplace($phpcod2"// PHP"$codstring);
  }
if (
stristr($codstring$javascr) !== false) {
   
$codstring str_ireplace($javascr"// javascript"$codstring);
  }    
if (
stristr($codstring$javascr2) !== false) {
   
$codstring str_ireplace($javascr2""$codstring);
  }

$codstring trim($codstring);
  
$codstring $phpcod ' '$codstring;
$resultstring highlight_string($codstringtrue);

$poisk1 '<span style="color: #0000BB">&lt;?php&nbsp;</span>';
$poisk2 '<span style="color: #0000BB">?&gt;</span>';

if (
stristr($resultstring$poisk1) != false) {
   
$resultstring str_ireplace($poisk1""$resultstring);
}

if (
stristr($resultstring$poisk2) != false) {
   
$resultstring str_ireplace($poisk2""$resultstring);
}

echo 
$resultstring;



The slider script  |  Zip unpacker  |  The script hit counter  |  Feedback script  |  Click to enlarge

AVL advertising materials rotator  |  How much is currently on the site.  |  Online program code highlighting

The script for the highlighting of program code  |  Form for uploading multiple images

Two examples of form code for uploading multiple images  |  Php handler for uploading multiple images to the server

Your comment or question

If you insert our link to your site at the address you wrote in the
comments, then your address will also become a link!