Discuz! 5. PHP code highlighting plug-in (updated by dancers in the dark ). Discuz! 5.0 forum display style php code highlight plug-in, the php code syntax coloring, like PHP comrades can easily read the code. Added the html code running function. This discuz! 5.0 forum display style php code highlighting plug-in,
Make the php code syntax coloring. comrades who like PHP can easily read the code.
Added the html code running function.
This plug-in was released by a previous comrade Discuz! 4. the php code is highlighted and the modification is complete.
In addition, my php learning has been stuck,
Hope someone can help me out of the learning difficulties of php
My QQ: 5642382. My QQ group: 2577162
Function: when posting a post, use the [php] php code [/php] Mark to highlight the php code,
Use the [runcode] Html code [/runcode] Mark to run HTML code (running non-server on the client ).
To add a plug-in, follow these steps:
1. modify include/common. js
Search
Function copycode (obj ){
Var rng = document. body. createTextRange ();
Rng. moveToElementText (obj );
Rng. scrollIntoView ();
Rng. select ();
Rng.exe cCommand ("Copy ");
Rng. collapse (false );
}
Add the following at the end of the function:
[Copy to clipboard] [-] CODE:
Function runCode (obj ){
Var winname = window. open (''," _ blank ",'');
Winname.doc ument. open ('text/html ', 'replace ');
Winname.doc ument. writeln (obj. value );
Winname.doc ument. close ();
}
Function saveCode (obj ){
Var winname = window. open ('', '_ blank', 'Top = 10000 ');
Winname.doc ument. open ('text/html ', 'replace ');
Winname.doc ument. writeln (obj. value );
Winname.document.execcommand('saveas', '', 'code.htm ');
Winname. close ();
}
2. modify include/discuzcode. func. php
Search
[Copy to clipboard] [-] CODE:
$ Discuzcodes ['codecs'] ++;
Return "[\ tDISCUZ_CODE _ $ discuzcodes [pcodecount] \ t]";
}
(Note: You can also use Editplus to directly find the 110th lines of code to add the following code)
Continue to add below:
/------- Add [runcode] Html code [/runcode] to run Html code
Function runcodedisp ($ code ){
Global $ discuzcodes;
$ Discuzcodes ['pcodecount'] ++;
$ Code = htmlspecialchars (str_replace ('\ "', '"', preg_replace ("/^ [\ n \ r] * (. + ?) [\ N \ r] * $/is "," \ 1 ", $ code )));
$ Discuzcodes ['codehtml'] [$ discuzcodes ['pcodecount'] ="
$ Code