Wednesday, October 24, 2012

Retrieve Remote file size with cURL PHP

Retrieve Remote file size with cURL PHP

Here's the best way (that I've found) to get the size of a remote file. Note that HEAD requests don't get the actual body of the request, they just retrieve the headers. So making a HEAD request to a resource that is 100MB will take the same amount of...

Saturday, October 20, 2012

Force file download in PHP

Force file download in PHP

PHP allows you to change the HTTP headers of files, so that you can force a file to be downloaded that normally the browser would load in the same window. This is perfect for files like PDFs, document files, images, and video that you want your visitors to download...

Friday, October 19, 2012

Block Multiple ip addresses in PHP

Block Multiple ip addresses in PHP

Sometimes you need to disallow a visitor to access your website. The most common reason for this is Spammers. Although there are several other solutions to block multiple IP addresses, but in this post we are going to focus on simple php script.<?php /* Online PHP Examples with Source...

Thursday, October 18, 2012

Get URL in PHP

Get URL in PHP

Below is a simple php function that return current page url<?php /* Online PHP Examples with Source Code website: http://4evertutorials.blogspot.in/ */ function currentURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL...
Date and Time Format like Facebook in PHP

Date and Time Format like Facebook in PHP

This simple PHP example will return a date and time format like facebook, generated from a mysql datetime field. Input Format: date('Y-m-d H:i:s')<?php /* Online PHP Examples with Source Code website: http://4evertutorials.blogspot.in/ */ function getDateTime($datetime) { $datetime=strtotime($datetime); $yesterday=strtotime(date('Y-m-d', mktime(0,0,0, date("m") , date("d") - 1, date("Y")))); $tomorrow=strtotime(date('Y-m-d', mktime(0,0,0, date("m") ,...
Mysql Database Connection in PHP

Mysql Database Connection in PHP

This is a simple example of how you could create a database connection from PHP to MySQL. It is good to save the MySQL Database Connection in a seperate php file in a secure part of the website. Then the file can be referenced in any page that requires...

Saturday, October 13, 2012

Validate Credit Card Number Using PHP

Validate Credit Card Number Using PHP

This piece of code will check if a creditcard number could possibly be valid, determined on the number ranges given. It will NOT actually validate the number with the creditcard company but it could function as a pre-check.<?php /* Online PHP Examples with Source Code website: http://4evertutorials.blogspot.in/ */ function...

Friday, October 5, 2012

Switch between multiple CSS styles sheets with PHP

Switch between multiple CSS styles sheets with PHP

A lot of webmasters like this nice looking CSS websites with the possibility to switch between different CSS style sheets. This code snippet will help to create the switch. Just create you different style sheets and your universal coded html documents (these one have to work with all the...
Custom Error Page with .htaccess PHP

Custom Error Page with .htaccess PHP

Create your own custom error page This custom error page shows some standard error information and reports the error to the webmaster by e-mail. The script works for dead links and will report expired hot links from other sites (the IP address). Just add bad URL's and IP addresses...

 

© 2014 4everTutorials. All rights resevered.

Back To Top