Parfum Shop's Blog

You come when you need, away when you get

Archives for the ‘Web Programming’ Category

Check if a URL exists and return code not 404(not found) with cURL PHP

By admin • Mar 24th, 2010 • Category: Web Programming

Here is a simple function that will do just that, determine if a website exists using PHP and cURL. It’s check http code, if http code is 404 (Not Found) it will return false.
function urlExists($url=NULL) {
if($url == NULL) return false;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpcode>=200 && $httpcode


Array remove empty entries PHP

By admin • Mar 18th, 2010 • Category: Web Programming

Bellow PHP code for remove an empty value of array:
function array_remove_empty($arr){
$narr = array();
while(list($key, $val) = each($arr)){
if (is_array($val)){
$val = array_remove_empty($val);
[...]


Detect Mobile Browser With PHP and JSP.

By admin • Feb 10th, 2010 • Category: Web Programming

Below listing code for detect browser is mobile or PC:
For PHP:


PHP Excel Export class

By admin • Feb 3rd, 2009 • Category: Web Programming

The class has a download() function that will send the appropriate headers for a binary download. Everybody knows phpMyAdmin can export file to Excel format but phpMyAdmin just export .csv file,not real Excel file format. If you are interest in PHP programming and need to export to the real Excel format please check it out
Download [...]


Advanced Count Word with PHP

By admin • Jan 22nd, 2009 • Category: Web Programming

Considering words are separated by spaces only into a text string, the next function might seem perfect for the purpose:
function count_words($str)
{
$no = count(explode(” “,$str));
return $no;
}


How to prevent email address harvesting

By admin • Jan 7th, 2009 • Category: Web Programming

Email address in HTTP redirect
One way to prevent email address harvesting is to write a server-side script to return the mailto:foo@example.com link as a HTTP redirect. All modern browsers recognize mailto in the page header but not every harvester is capable of understanding this. Here is an example showing how this can be done in [...]