The Google Analytics API and PHP: A series

The Google Analytics API is a powerful tool for accessing analytics data without having to log into the web interface and means you can easily have automated processes for collating data and saving it to a database, emailing information on a daily basis etc.

I have created a PHP class for accessing the Google Analytics API with CURL and using DOMDocument to parse the XML. The resulting class and example script can be downloaded here and there are a number of posts on this website showing how to use it.

Categories PHP

PHP’s ini_get_all function

PHP has a large number of configuration options which can be set in the php.ini file, Apache virtualhost settings, .htaccess and with the ini_set function. This post looks at the ini_get_all function which returns an array containing all the possible configuration options, what their global and local script value are and where they can be modified.

Categories PHP

Log PHP errors with log_errors and error_log

PHP errors are by default logged to the web server’s error log file (at least they are with the default setup on most Linux distros) but it is also possible to instead log PHP errors to a file of your choice. This is useful on production websites so you can periodically check for errors and fix them in a location other than the default webserver error log file.

Categories PHP

Automatically append or prepend files in a PHP script

It is possible with PHP to automatically append or prepend a file to a script using the auto_append_file and auto_prepend_file configuration options. These options can be set in the PHP config, virtualhost settings or in a .htaccess file. This post shows how to set these and how to override a setting so no file is appended or prepended.

Categories PHP

PHP’s getdate() function

I’ve been coding PHP since 1999 and I’m still discovering functions I didn’t know about. Just the other day I read someone’s post about some useful PHP functions and I knew all of them except for the getdate() function so I thought I’d cover it here.

Categories PHP

Get a list of all available classes with PHP

PHP has the function get_declared_classes() which allows you to get a list of all the available system and user defined classes in an array. This post looks at how to use the get_declared_classes() function, the output from it and how to sort the list into alphabetical order. Using get_declared_classes() get_declared_classes() returns a zero based array …

Read more

Categories PHP