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…
Category: PHP
How to Get Start & End dates of a Week by given Date
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…
How to know whether a file exists in URL using PHP
In PHP, to find whether a file exists in disk or on server we have: if(file_exists($filepath)) However is there a way to know whether a file exists in an url, such as, https://www.google.co.in/images/nav_logo242.png?
Create pdf preview thumbnail using php
Following the stackoverlow answer http://goo.gl/z9IWCB I did everything correct as mentioned in the answer to create pdf preview thumbnail using php but I struck with an error as such as this. error no decode delegate for this image format `\path\filename.pdf’…
Fully-formatted Time Difference between two Dates
An useful php function to calculate a time difference between two dates given in sql format. If the newer date is not passed as second argument it would calculate the different between the old date and current time. So it…
Create php array from select options
There are many ways to create a dropdown select options list from a given array in any programming language like PHP. Please check how to create a select list from a PHP array. However in this case I will make…
Useful PHP debug functions
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…
To print the table structure of MySQL table in PHP
You can print the table structure of MySQL table in PHP using simple php script. All you need to do is to make a ‘describe table’ call and process it using php script, similar to one you use to print…
PHP – Fix apostrophe(‘) converting to entity ' in csv export
1) If you read a .csv file for download: use \xEF\xBB\xBF after headers and just before you echo file data. For example: echo “\xEF\xBB\xBF”; // UTF-8 BOM readfile($file); 2) If you echo per line use htmlspecialchars_decode to covert single and…
How to get file extension using PHP
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…