A simple way to debug a php application in production mode

How to get file extension using PHP

A simple way to debug a php application in production mode

A simple yet powerful approach to get file extension using PHP. We usually need to extract file extension from file name while uploading file so that we could generate new name and rename file to our convenience. We could create new file name using time, random or hashing, example of which has been given at the last paragraph of this post.

function get_file_extension($filename) {
    return substr($filename, strrpos($filename, '.')+1, strlen($filename)-strrpos('.', $filename));
}

Explanation:

It uses built-in substring, strrpos and strlen functions to extract file extension. A brief on these functions. Continue reading

wordpress logo

WordPress + Web.config “not found” error on home page

wordpress logo

I was trying to setup wordpress on IIS when i faced this problem. I placed a web.config file with given xml code and pretty urls (permalinks) worked fine on all page except the home page. Home page gave a Not Found error while pretty permalinks worked find on all other pages. After adding the following code (given below) in system.webServer settings to web.config it worked find. In short the code given below adds index.php as a default document root. Continue reading

wordpress logo

How to Fix the “URL is Unreachable” Error in Facebook Comments

wordpress logo

Recently, i have been setting up the Facebook Comments plugin on my client’s server. Before trying it on live server i tried to set it up on my development server. It looked to work but with a error “Warning: http://coolum.inimist.com/?p=1 is unreachable.“ where http://coolum.inimist.com is my development server. I searched around and found an easy fix. Continue reading

Active Collab Logo

Creating custom authentication or one time access page in ActiveCollab

Active Collab Logo

Creating a one time authentication in ActiveCollab. The example was taken from the developer’s guide at ActiveCollab website. When i checked this one first time the file structure mentioned in the guide and the actual file structure in AC 3.1.16 looked different, and it was further changed in current 3.3, hence posting it for reference here. Continue reading

A simple way to debug a php application in production mode

Useful php debug function to output data with line number

A simple way to debug a php application in production mode

A very useful php debug function i like to use to print debug output to browser window. In some cases where i may not output the debug to browser window i use the same php debug function to receive debug output in my email inbox.

We usually use print_r or var_dump to show debug output. This php debug function uses print_r by default but one can use var_dump to show the output. Continue reading