Tag Archives: PHP

A simple way to debug a php application in production mode

How to know the location of a function defined in PHP

A simple way to debug a php application in production mode

Sometimes you want to know the location of a function defined in your php application. For example you are debugging a large online web application or website. To continue debug you want to enter into a function to debug. You don’t have an easy way to download all the files to your location system to do a text search. Also you don’t have access to file system search capabilities on the server. How to get into the function? Continue reading

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

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

Caching large menus or header/footer links in WordPress

Even if you are not using some robust caching plugin or tool in wordpress you can cache small chunks of data using basic caching techniques of PHP. In my example i had been creating a few dozens of links in the footer i would cache my links part so every time my page loads wordpress does not have to create each and every link by querying the database for each individual link. Here’s the simple code: Continue reading

How to debug a php application in production/live mode

A simple way to debug a php application in production modeHow to debug a live website built in php?

Here’s a basic, simple and custom method i usually use to debug live or production web applications (web sites).

First of all i place the following lines of code in a config.php or somewhere so it is loaded in all targeted pages of the website. Continue reading