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…
Category: PHP
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…
Useful php debug function to output data with line number
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…
Ideal way to perform email validation in php
I found this email validation function while working in ActiveCollab. By default, this function uses PHP’s inbuilt filter_var function to validate email, which is supported in PHP 5 (> 5.2.0). If version of PHP is older (is less than 5.2.0)…
Covert PHP config size values to bytes
Convert PHP config value (2M, 8M, 200K…) to bytes. Use full when converting values received, for an example, through ini_get(‘memory_limit’).
Ideal way to define directory separator in PHP
Ideal way to define directory separator in PHP // Directory separator if(!defined(‘DIRECTORY_SEPARATOR’)) { define(‘DIRECTORY_SEPARATOR’, strtoupper(substr(PHP_OS, 0, 3) == ‘WIN’) ? ‘\\’ : ‘/’); } // if
Creating a module in ActiveCollab3
One page guide on creating a new modules to create home screen widget in ActiveCollab3 application. First we need to create a directory for our module. We are going to create it under a /path/to/activecollab/custom/modules directory (where /path/to/activecollab is full…
Creating and Parsing JSON data with PHP
What is JSON? JSON is ultra-weight data interchange data format used over the internet for transferring the data. While XML is a dominant data interchange format over the internet but JSON is less complex and light-weight data.