Archive for the ‘PHP’ Category

 

Fatal error: Call to undefined function exif_read_data() in www\index.php on line 10

I recently got this error while trying to read EXIF data from jpegs.
So I enabled exif extension in php.ini but when I restarted Apache
I was informed that “php_exif.dll cannot not be found”.
I checked “ext” directory of my PHP installation and the file was there.
After doing some research I discovered that in order to use EXIF [...]

PHP: How to safely include file with possible parse errors?

Recently I had written a class and it had to save bits of information somewhere. I wanted to make the script installable just by placing it on a server so I didn’t want to use any database. Instead I figured out I should save the data in a simple file. I could use serialize and file_put_contents which is very easy to write, but modifying such files manually in a text editor is a nightmare. So I decided to save the contents in a PHP file.
Unfortunately if there is an error in such file you will get parse error when including it.

PHP: Date format for sitemap.xml

Sitemap.xml files require special date format. Example valid date is: 2010-10-06T11:56:00+01:00

Magento Error: Method Varien_Object::__tostring() cannot take arguments

If you encountered a bug in Magento that says:
Method Varien_Object::__tostring() cannot take arguments
and you have PHP 5.3 or newer then you have 2 options:
1) downgrade to PHP 2.9
2) fix the bugs

PHP: Convert Youtube links in text into embedded videos

Here’s a nice function I wrote which can convert any youtube links found in a string into embedded videos.

How to show more tags in Wordpress tag cloud?

WP by default shows 45 tags in a tag cloud displayed in sidebar. If you want to change this value then open file wp-includes/category-template.php and look for function wp_tag_cloud.
If you have it then change value 45 to anything you want- for example 60. After you do it you should end with something like this:

function wp_tag_cloud( [...]

Import Excel (XLS) document into MySQL database

The best way to read XLS files in PHP is using PHPExcelReader. It’s a great class becasue it does not use any COM objects, however the download package on SourceForge sometimes contains invalid XLS or example files, so I prepared a working package and you get get it here.

Read and write BMP in PHP: imagecreatefrombmp + imagebmp

This is an updated class to use BMP format in PHP. Previous version is
here. If all you need is loading and saving 24bit BMP files- you can use previous version. It has less code so works a bit faster.
This version saves 24bit BMP files and loads 1, 4, 8, 24 and 32 bit BMP files.

Extract title, author and number of pages from PDF with PHP

Here’s a PHP class I wrote which can be used to get title & author and a number of pages of any PDF file.
It does not use any external application- just pure PHP. The class is licensed under MIT, so it is as free as could be :)

PHP Class: How to read ID3v2 tags from mp3 files

To read Id3 v2 tags from any given mp3 file you can use the attached PHP class. Usage is very simple:

 
TopOfBlogs Web Development & Design Blogs