Category 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 Start & End dates of a Week by given Date

A simple way to debug a php application in production mode

The following function gets start and end date of a week for a given date supplied in valid date string format. In the following function $week is the number of week in the year. For example the current week is week number 43. In the following function $year is year in YYYY format. For example, current year which is 2016. Here is the function to get start date and end date by a given date. For example
_getWeekStartEndDatesByDate(‘2016-10-26’)

function _getWeekStartEndDatesByDate($current_date) {
$week = date('W', strtotime($current_date));
$year = date('Y', strtotime($current_date));
return _getWeekStartEndDatesByWeekAndYear($week, $year);
}

function _getWeekStartEndDatesByWeekAndYear($week, $year) {
$dto = new DateTime();
$result['start'] = $dto->setISODate($year, $week, 0)->format('Y-m-d');
$result['end'] = $dto->setISODate($year, $week, 6)->format('Y-m-d');
return $result;
}

I hope someone finds it helpful.

A simple way to debug a php application in production mode

Useful PHP debug functions

A simple way to debug a php application in production mode

Here are a few useful PHP debug functions.

I wrote a similar post sometime ago posting the abbreviated “pr” function as a shorthand replacement for the “prinr_r” or “var_dump” functions. Since then this function has changed a bit so re-posting it here with the improvements. With the new updated function one can restrict the output to screen for specific IP address only. Continue reading