Check If Viewed Through Mobile

On many occasions, you may want to check if the current visitor is browsing your site through a mobile browser. There are a lot of solutions out there (classes, libraries), but the simplest option has...

Get the Current URL of Page with PHP

This simple snippet of code will help you get the full URL of the currently viewed page. function getUrl(){ $domain = $_SERVER['HTTP_HOST']; $url = "http://" . $domain . $_SERVER['REQUEST_URI']; retur...

How to Grab Youtube Video Thumbnail?

Getting the thumbnail of a Youtube video through it’s ID is not that hard. You just have to transform the URL a little bit to get a high quality JPG file, used as a main thumbnail through Youtub...

How to Fix a “unexpected $end” Error

Sometimes you will get an error similar to this in PHP: Parse error: syntax error, unexpected $end in /index.php on line 36 This is most likely caused by a forgotten closing curly bracket (“}...

How to Set a Cookie to Never Expire

Sometimes, while working with Cookies in PHP you may want to make a cookie never expire (e.g. in a rating script where you set a cookie on user’s computers, although it’s not wise to use c...

PHP Login Script Example

This PHP login script example is a very simple login system which you can use as a base for your future projects. You should note that it needs to be secured before using on a live system. Some things...

Simple PHP HTTP Authentication

Sometimes you may want to hide the contents of a page (e.g. admin page) in a very simple manner. The best and simplest method is to use the PHP’s built in HTTP authentication. It’s both se...