CategoryPHP

SEMrush keeps taking down my site

S

My site is being absolutely bombarded by page requests originating from semrush.com. Its a bot that is¬†indexing and downloading links to my entire site, which would be fine if it were a small website, except that I have content going back to 1996, which is rather a lot, and they are hitting the server with so many requests that Apache2 and/or MySQL Server 5.7 is crashing. It’s utterly...

Terminal – calculate number of lines of code in a directory

T

We had an interesting question, can we calculate how many lines of code we have written for an entire project? It turns out this isnt the easiest thing to calculate for a web-project, but we gave it a go. This is the best we have come up with so far for all code we have written to calculate the number of lines of code in all PHP, CSS, JS, HTML and HTM pages. ( find ./ -name '*.php' -print0 -o ...

PHP Function to replace all new line characters in a string with BR tag

P

There is an incredible but little known built-in function with PHP that replaces all new line characters within a string with html <br /> tags. Its perfect if you ever want to display the contents of a text area within HTML. $str = nl2br($str); This will replace all new line characters with valid XHTML <br /> tags. There is also an optional parameter to turn of XHTML and just use...

Archive

Tags

Get in touch

I'm available on just about every social media platform out there as RMTWeb.