Installing syntaxhighlighter error: XregExp not defined

I recently installed syntaxhighlighter. The useful JavaScript tool for professional formatting of code blocks for blogs etc. by Alex Gorbatchev.

I followed the installation guide properly adding the shCore.js and brush scripts I needed. I also included shCore.css and shThemeDefault.css style files but kept receiving the same JavaScript error: XregExp not defined in shCore.js

It turns out after a lot of trial and error that you do not use the JavaScript files in the "/src/" folder of the download files. These do not work. You must use the 3 files with the same name in the "/scripts/" folder, specifically:

  • shCore.js, 
  • shLegacy.js 
  • shAutoloader.js

Find current URL using PHP

If you've ever wanted to find the complete current URL of the page you are on using PHP, it's easy using PHP's built in $_SERVER global variables.

'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

To break it down, we start with a string writing the "http://".

We then use the period (.) character to concatenate on the server name. $_SERVER['HTTP_HOST'] returns the name of the server. e.g. 'localhost' or 'www.blakes-site.co.uk'.

Finally we concatenate on $_SERVER['REQUEST_URI'] using the period character again. Request URI returns the current page you are accessing on the server e.g. '/blog/view.php'

To show a URL without the 'http://', for simpler presentation simply don't add this string at the start.

$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

© Blake Simpson, 2012 – 2019