News & Blog

Plesk Container Not Accessible After Deleting Admin MySQL User

September 28th, 2011 - Posted by Steve Marks to MySQL, Server Management, Web Development.
Whilst recently carrying out a security audit, one of the tasks on my list was to refine the permissions that MySQL users have. One of the users in the list was called ‘admin’. It had full permissions to all databases which struck me as a bit unsafe so, seeing as I wasn’t...

Loop Through Letters in a String with PHP

September 23rd, 2011 - Posted by Steve Marks to PHP, Web Development.
Iterating through a string to get each letter can be easily achieved with PHP. The example below shows how this can be done with a for loop: $string = "HelloWorld"; for ($i=0; $i<strlen($string); $i++) { echo $string[$i]."."; } // Outputs: H.e.l.l.o.W.o.r.l.d. Notice how we reference th...

Jump to Top or Bottom of File Using the Nano Linux Command

September 23rd, 2011 - Posted by Steve Marks to Server Management, Web Development.
When viewing and editing files, Linux’s nano command can be very useful. One of the primary reasons for my usage of nano is reading log files that can be hundreds, if not thousands of lines long. In this scenario one of the most useful commands required is to quickly jump to the top ...

PHP Benchmark – sha1_file() vs sha1(file_get_contents())

September 16th, 2011 - Posted by Steve Marks to PHP, Web Development.
When working on a recent project the need came up to produce a SHA1 hash of a file to allow comparisons between new and existing files. I knew that I could easily create a hash of a file using PHP’s sha1_file() function but I was unsure on the performance and speed of it, bearing in ...

Capturing and Handling PHP Errors Gracefully

September 6th, 2011 - Posted by Steve Marks to PHP, Web Development.
Capturing errors are essential in reducing bugs and debugging PHP code. Whether it’s a simple undefined variable or a more complex memory allocation error, it’s important that you are made aware of these errors. Not only that but if a frontend user sees an error, or if somethin...