Posts Tagged with "php"

Shorten a string…

Wednesday, October 12, 2011

0 Comments

This simple function returns a shorten string back.

Continue reading...

How to calculate distance between two locations

Wednesday, October 12, 2011

0 Comments

A very useful function that can be used to calculate distance between two points using latitude and longitude values. $unit parameter can be passed to get return in miles, kilometers, or nautical miles. How to use: Another function:

Continue reading...

Login into a Joomla website using PHP and CURL

Wednesday, September 7, 2011

1 Comment

Following PHP script uses CURL to login into a Joomla 1.5 website to access private pages.

Continue reading...

Creating zip archives in PHP

Monday, September 5, 2011

0 Comments

PHP comes with a ZipArchive class that lets us create and manipulate .zip files. Creating a Zip file using PHP Following code will create master.zip with files containing master.css, new.css, layout.css Extracting a Zip file using PHP

Continue reading...

How to install mcrypt for PHP in ubuntu

Sunday, September 4, 2011

0 Comments

On my Ubuntu 4.9 with PHP Version 5.3.2-1 I had to install Magento that required myscrypt. To install it, I followed following steps: Sometimes you might get the message “php5-mcrypt is already the newest version“. If so, install with:

Continue reading...

CURLOPT_FOLLOWLOCATION warning message

Friday, August 26, 2011

0 Comments

While developing a twitter extension I came across following warning message on my Ubuntu development server. After doing some research I found that curl follow location option tells curl to follow a redirect header or not. If the environment in the php.ini is running php in safe mode or an open base dir is set, […]

Continue reading...

How to enable CURL on WAMP local server

Thursday, August 25, 2011

2 Comments

I needed CURL to test some php scripts on WAMP Local Server where CURL is disabled by default. To enable it under WAMP running on a Windows Environment follow these steps.

Continue reading...

Log an entry into Joomla Log

Wednesday, August 24, 2011

1 Comment

Joomla’s JLog class enables to create log files with useful debug info and other log messages. Following is the PHP code that can be used to log messages.

Continue reading...

A function to generate unique id’s and keys

Wednesday, March 2, 2011

0 Comments

Following function will generate id’s/keys without using MD5 or SHA1. PHP function uniqid() to generate Unique ID’s. It will create prefixed unique identifier based on current time in microseconds. This function will return (13 + prefix length) characters long identifier. If ‘lcg’ is true then it will return (prefix length + 23) characters. This function […]

Continue reading...

Finding Domain Name from URL in PHP

Tuesday, September 21, 2010

1 Comment

Following are various functions to find domain name in URL using PHP. Regex Method:

Continue reading...