Code Snippets

Write data to text file in PHP

by itwebresources on May 15, 2013

This PHP code snippet writes text data to a given file. If file name does not exist, the file is created. Otherwise, the existing file is overwritten. This function is similar to above, except if file name already exists, append the data to the file instead of overwriting it.

{ 0 comments }

Download File with a Speed Limit in PHP

by itwebresources on May 14, 2013

This snippet allows you set a limitation for download rate of the file that visitors download from your site.

{ 0 comments }

Measuring page load time in PHP

by itwebresources on May 14, 2013

This is simple code snippet to measure page load time in PHP. This can be crucial for your web server if your php scripts load slow and take most of the CPU and RAM resources. Place the following code at the very top of your PHP page (if you measure the time needed for particular [...]

{ 0 comments }

Send mail using mail function in PHP

by itwebresources on May 14, 2013

You can use the PHP mail() function to send an email with PHP. The simplest way to do this is to send a text email. Although is seems like a very trivial and easy to accomplish task sometimes there can be unexpected obstacles. In the code snippet example below we show you how to send [...]

{ 0 comments }

Web page auto-redirecting methods and code snippets

by itwebresources on May 7, 2013

Web page auto-redirecting is automatically sending a site visitor to another page once that visitor has landed on a page. The other page is often on the same website, but it can be on a different site altogether. Here are a few ways to redirect after a certain number of seconds. HTML, PHP, and Javascript [...]

{ 0 comments }

How to get current page URL in PHP

by itwebresources on March 23, 2013

Sometimes, you might want to get the current full URL in PHP. This PHP code snippet will also find out if the URL is on a secure URL or not, gets the server name and port number if needed and the current page.

{ 0 comments }

Handy Byte Convertor Function

by itwebresources on October 23, 2012

This is handy function for converting bytes to KB, MB, GB, etc.

{ 0 comments }

Code snippet to get real IP address of client

by itwebresources on October 23, 2012

PHP code snippet to get real IP address of client even if he is behind a proxy server.

{ 0 comments }

Code snippet to check if server is running HTTPS

by itwebresources on October 23, 2012

This is a handy little code snippet to check if server is running HTTPS. Nothing complicated simple PHP code!

{ 0 comments }

Convert .pdf files to .jpg using PHP and Image Magick

by itwebresources on October 23, 2012

This is a simple code snippet to convert a .pdf file into a .jpg image. Please note, you must have the Image Magick extension installed on your server to use this snippet. Credits: http://snipplr.com/view/48513

{ 0 comments }