PHPPHP

Information and howto articles for PHP

PHP is a powerful open source server-sided scripting language that can be used on a wide variety of operating systems and webservers, including Apache on UNIX and IIS on Windows.

PHP contains numerous extensions which enable you to dynamically create images and flash files, parse xml, connect to remote servers using pop, imap, ftp, http and raw sockets, natively access many database servers including PostgreSql, MySQL and Microsoft SQL Server, compress and decompress files, lookup domain names and and much more.

PHP has an excellent manual and online documentation which covers every function for every extension available.

Post sort order: Post Date (Newest First) | Post Date (Oldest First) | Alphabetical | Date Updated

Get a mail server's IP address with PHPGet a mail server's IP address with PHP

Posted November 9th, 2012 in PHP

Some time back ago I posted how to do email validation in PHP with the filter_var function (here and here) and have recently been asked how you would determine if the domain is valid. There are a few ways of doing this and I suggested doing DNS lookups. In this post, I show how to work out a mail server's IP address using DNS lookups with PHP.

Read more »

Configuration options to fix some phpMyAdmin annoyancesConfiguration options to fix some phpMyAdmin annoyances

Posted October 26th, 2012 in MySql and PHP

I use phpMyAdmin as a PHP web based manager for MySQL, but find a few of the default configuration options "out of the box" a little annoying. This post shows some useful modifications to the defaults to make phpMyAdmin more usable, in my opinion.

Read more »

PHP suhosin, sessions and shared SSL certificatesPHP suhosin, sessions and shared SSL certificates

Posted May 10th, 2012 in PHP

There's a patch for PHP called suhosin which is part of the Hardened PHP Project to make PHP more secure. I came across an issue with the way session data is encrypted when using a shared SSL certificate on an old osCommerce install I occasionally have to support.

Read more »

Extract inline image attachments from an email with PHPExtract inline image attachments from an email with PHP

Posted April 13th, 2012 in PHP

A month ago I posted a PHP email message class for extracting attachments and have been asked by a couple of people how to extract inline images and make it so they can appear in the HTML content of the email. This post shows how to do this, using my email class to get the email.

Read more »

PHP email message class for extracting attachmentsPHP email message class for extracting attachments

Posted March 15th, 2012 in PHP

I've done a bit of work in the past extracting attachments from email with PHP and posted a few articles here showing how to do it. None of them have really been all that satisfactory and so a little earlier this year I started again from scratch. I've posted here what is a work-in-progress due to requests from several people. It's not complete but it does work.

Read more »

PHP script to check MySQL replication statusPHP script to check MySQL replication status

Posted February 17th, 2012 in MySql and PHP

If you have MySQL replication running in either a master-slave or master-master type setup then don't assume everything is running perfectly all the time. Power cuts and other disasters do happen so you need to check periodically to ensure it's all working. This post has a PHP script to check for any MySQL replication errors and then emails if there are any issues

Read more »

Sending a header using the PHP SOAP clientSending a header using the PHP SOAP client

Posted February 2nd, 2012 in PHP

I've recently been interfacing with a SOAP API on a .NET server and also creating an API in PHP, and both require sending a specific SOAP header for authentication. This post shows how to send a SOAP header using the PHP SOAP client which is built into PHP.

Read more »

PHP $_SERVER variables - CLI via SSH vs cronPHP $_SERVER variables - CLI via SSH vs cron

Posted January 31st, 2012 in PHP

I have a number of batch processes that run using PHP as the command interpreter, and discovered after making a change to one of them the other day that the variables available to PHP in the $_SERVER superglobal are different depending on whether it's run via an SSH session or cron. This post shows the difference on Debian 6. The values available are probably the same on other distros.

Read more »

Restore the admin toolbar when logged into WordPressRestore the admin toolbar when logged into WordPress

Posted January 12th, 2012 in PHP

I don't use WordPress myself, but one of website partners does for their blog. We recently both upgraded from WordPress 2.7 to 3.3 and changed the layout of the website and either as a result of the upgrade or the theme change, lost the admin toolbar that appears at the top of the page when logged in as as admin.

Read more »

Get message body and attachments using PHP IMAPGet message body and attachments using PHP IMAP

Posted January 11th, 2012 in PHP

The last post looked at how to get a message structure using the PHP IMAP functions into an easier to use flat array. This post looks at how to loop through that array to easily get all the message parts and attachments.

Read more »

Fetch message parts into a flat array with PHP IMAPFetch message parts into a flat array with PHP IMAP

Posted January 10th, 2012 in PHP

The PHP IMAP functions imap_fetchstructure and imap_fetchbody are used to work out the structure of an email and get the message body and attachments, but they can be fiddly to use because the message parts can be nested. This post has a function which effectively flattens the message parts into a new array, indexed by the part number which can be directly passed to imap_fetchbody.

Read more »

How to use static variables in a PHP functionHow to use static variables in a PHP function

Posted January 9th, 2012 in PHP (Updated January 24th, 2012)

There may be times when a static variable is needed in a PHP function; static variables maintain their value between function calls and are tidier than using a global variable because they cannot be modified outside of the function.

Read more »

Escape characters in the PHP date functionEscape characters in the PHP date function

Posted December 9th, 2011 in PHP

It's funny when you've been programming in a language for a long time and fall into odd assumptions about particular functions. For some reason I appear to have assumed there was no way to escape characters in PHP's date function. Then yesterday I saw some sample code where a character was escaped and double checked in the manual. Sure enough, you can escape characters and it's obvious. I just thought I'd share it here in case you're making the same mistake I was.

Read more »

Allowed memory size exhausted with the PHP Simple HTML DOM ParserAllowed memory size exhausted with the PHP Simple HTML DOM Parser

Posted November 5th, 2011 in PHP

The Simple HTML DOM Parser is a useful tool for extracting content from web pages using jQuery like syntax. If multiple pages are loaded into the parser the available memory will eventually be exhausted and a fatal error will occur.

Read more »

phpMyAdmin "Cannot start session without errors"phpMyAdmin "Cannot start session without errors"

Posted September 6th, 2011 in PHP

Sometimes phpMyAdmin is inaccessible and gives the error message "Cannot start session without errors". This can be due to either a client-sided issue with cookies, or a server-sided issue relating to permissions of the temporary directory where session files are stored.

Read more »

MySQL connections and PHP forked processesMySQL connections and PHP forked processes

Posted July 5th, 2011 in MySql and PHP

It is possible to fork a process with PHP and have one or more child processes running. If a connection has already been established to a MySQL database and the child processes run queries it's quite likely a "MySQL server has gone away" or a "Lost connection to MySQL server during query" type error will occur.

Read more »

PHP script to convert MySQL tables to a new storage enginePHP script to convert MySQL tables to a new storage engine

Posted June 27th, 2011 in MySql and PHP

MySQL supports multiple storage engines which each have their pros and cons; the two most commonly used are MyISAM and INNODB. It's easy to convert a table from one storage engine to another, and this post has a PHP script which convert all tables in a MySQL database from one engine to another.

Read more »

Testing if a PHP include file was includedTesting if a PHP include file was included

Posted June 9th, 2011 in PHP

PHP's include() and include_once() functions can return values to the calling script which can be useful for testing to see if the file was actually included, for example if a configuration file whose filename is based on the website's domain name was included. If no return value is set then it will return integer 1 if included, or boolean false if not.

Read more »

Prevent E_DEPRECATED error messages in PHPPrevent E_DEPRECATED error messages in PHP

Posted May 27th, 2011 in PHP

PHP 5.3 introduced a new error reporting level E_DEPRECATED which is triggered when deprecated functions and methods are used, such as the old style ereg() regular expression functions. This post shows how to suppress E_DEPRECATED error messages.

Read more »

PHP script to export table creation SQL from MySQLPHP script to export table creation SQL from MySQL

Posted May 10th, 2011 in MySql and PHP

I was trying to export the structure of a MySQL database using phpMyAdmin but it kept timing out and not showing me the full create script. I think phpMyAdmin uses the information schema to get this information and its on a host with hundreds of databases and tables so querying the information schema runs very slowly. Instead I knocked together a quick PHP script to dump the structure instead and share it here.

Read more »

PHP parse_url error for https requests from "Test Certificate Info"PHP parse_url error for https requests from "Test Certificate Info"

Posted April 28th, 2011 in PHP

The PHP websites I manage email me all notices, warnings and errors and I occasionally get warnings resulting from bots requesting bad URLs. This post looks at a PHP parse_url error caused by an incorrect piece of code that was published which has since been corrected, but there are clearly still scripts out there using the old code and making bad requests.

Read more »

Set TinyMCE options with SilverStripeSet TinyMCE options with SilverStripe

Posted January 5th, 2011 in PHP and SilverStripe

The SilverStripe/Sapphire CMS/Framework uses TinyMCE as the HTML editor. Normally to set configuration options for TinyMCE you would do it in your own tinyMCE.init() call, but in SilverStripe this is called dynamically in PHP in core Sapphire code. There's a simple way to add configuration options as shown in this post.

Read more »

SilverStripe and PHP version requirementsSilverStripe and PHP version requirements

Posted December 29th, 2010 in PHP and SilverStripe

This post looks at the minimum PHP version requirements for SilverStripe. I will update this page as new versions are released and I upgrade the various SilverStripe websites I manage, noting any issues I experience.

Read more »

PHP: get keywords from search engine referer url - version 2PHP: get keywords from search engine referer url - version 2

Posted November 26th, 2010 in PHP

I posted how to get the keywords from a search engine referer url a while back (here) and from a number of useful comments on that post have completely revised the function which now also supports the query string when it is sent as part of a URL fragment.

Read more »

PHP snippets to interact with TwitterPHP snippets to interact with Twitter

Posted November 16th, 2010 in Offsite Articles and PHP

Jean-Bapiste Jung compiled a useful collection of PHP snippets to interact with Twitter over at Cats Who Code. All the code you need is included with a link back to the originating website.

Read more »

MAMP PHP cURL and SSLMAMP PHP cURL and SSL

Posted November 13th, 2010 in PHP

I currently develop PHP based websites on a Mac using MAMP. When testing the Interspire Email Marketer API on a local version of a site posting data through to an https:// URL with cURL, I discovered that the version of cURL on MAMP has some issues with certs and SSL.

Read more »

var_dump or print_r inside a Smarty templatevar_dump or print_r inside a Smarty template

Posted November 9th, 2010 in PHP

While trying to debug why something wasn't working, I needed to see what data had been assigned to a Smarty template but from within the template itself (I didn't have time to try and work out where in the PHP code the stuff was assigned and debug from there). This post shows how to do a var_dump or print_r from within the Smarty template itself.

Read more »

PHP for loops with multiple statements in each expressionPHP for loops with multiple statements in each expression

Posted October 20th, 2010 in PHP

PHP for loops work in the same way as other programming languages and have a useful feature where each expression between the semi-colons can have multiple statements to be executed when separated by a comma. I found this useful myself when I need to have both a zero based and 1 based index in a loop.

Read more »

Using an include file for footer links with PHPUsing an include file for footer links with PHP

Posted August 30th, 2010 in PHP

I was asked an interesting question by email over the weekend and thought I'd share my response here. The question was "I wish to include in the footer links to my other developed websites. I don't wish to update the footer on each html page every time I create a new webpage. What would be your advice for implementing something like that using html, js and css".

Read more »

PHP: get keywords from search engine referer urlPHP: get keywords from search engine referer url

Posted August 16th, 2010 in PHP (Updated November 26th, 2010)

This post shows how to use PHP to extract the keywords searched on by a user when they found your website using a seach engine. Bing, Google and Yahoo are covered here and you can easily add your own to the PHP code supplied.

Read more »

PHP email validation with filter_var - updatedPHP email validation with filter_var - updated

Posted July 23rd, 2010 in PHP (Updated November 9th, 2012)

Just over a year ago I posted how to validate email addresses with PHP using filter_var instead of having to mess around with regular expressions. As pointed out in a comment, chris@example will pass validation; while that is actually a valid email address (the domain part of an email address doesn't actually have to have dots in it, e.g. localhost) in most real situations we don't want it to validate so this post adds a regular expression to the test to ensure the part after the @ contains a dot.

Read more »

Create thumbnails from images on a webpage with PHPCreate thumbnails from images on a webpage with PHP

Posted July 20th, 2010 in PHP (Updated September 15th, 2010)

In previous posts I have looked at how to extract images from a web page with PHP and the Simple HTML DOM Parser and generate thumbnails with PHP using a class I created. This page combines the two by downloading all the images from a specified web page and creating thumbnails for them.

Read more »

PHP Quick Tip: Check if URL aware fopen wrappers are enabledPHP Quick Tip: Check if URL aware fopen wrappers are enabled

Posted July 19th, 2010 in PHP and Quick Tips

PHP supports opening remote URLs (e.g. http://www.example.com/something.htmnl) using the fopen and similar functions. It is possible to disable this function in the PHP configuration so this quick tip shows how to check if it is possible to open remote URLs.

Read more »

Generate thumbnails with PHPGenerate thumbnails with PHP

Posted July 16th, 2010 in PHP

There are many examples and tutorials online about how to generate thumbnail images with PHP but I decided to add another one myself in order to follow up an earlier post titled "extract images from a web page with PHP and the Simple HTML DOM Parser". This post features the class to generate the thumbnail images and the next post will show how to use the Simple HTML DOM Parser to grab all the images from a page and create thumbnails from them.

Read more »

Turn off PHP on ApacheTurn off PHP on Apache

Posted July 14th, 2010 in Apache and PHP

This post is a response to a question asked on my "Disable PHP in a directory with Apache .htaccess" article asking how to disable PHP completely in Apache, or as it was asked: "Could you tell me how can I turn off PHP on Apache (Run Apache without PHP)".

Read more »

Cookies and domainsCookies and domains

Posted May 24th, 2010 in Javascript and PHP

A little while back I posted how to set cookies with jQuery and was asked about the domain setting and how setting the domain affects sub domains. This post explains how cookies and domains work, and covers some tests I did to check my assumptions were correct.

Read more »

PHP Quick Tip: use __DIR__ instead of dirname(__FILE__) from PHP 5.3PHP Quick Tip: use __DIR__ instead of dirname(__FILE__) from PHP 5.3

Posted May 13th, 2010 in PHP and Quick Tips

The traditional way of getting the directory the current file is in with PHP is to use dirname(__FILE__). From PHP 5.3 there is a new magic constant__DIR__ which is the equivilent of this function call.

Read more »

PHP command line syntax checkingPHP command line syntax checking

Posted April 24th, 2010 in PHP

The PHP CLI (command line interface) allows basic syntax checking of a PHP file. I'll show the basic usage of this in this post and then a couple of ways to check all files in a directory, and all files recursively down the directory tree as posted by a couple of people on Twitter.

Read more »

Disable PHP in a directory with Apache .htaccessDisable PHP in a directory with Apache .htaccess

Posted March 29th, 2010 in Apache and PHP

If you have a directory which users can upload files into it's a good idea for security reasons to disable server-side parsing of scripts such as PHP. This post shows a couple of options using Apache's .htaccess files.

Read more »

PHP's file_get_contents and CURL functionsPHP's file_get_contents and CURL functions

Posted March 25th, 2010 in PHP (Updated November 16th, 2010)

This is a summary of the posts I've written about PHP's file_get_contents functions when used to download remote content (e.g. webpages, XML files, images etc) and the CURL functions which are used to do the same thing.

Read more »

PHP Caching HeadersPHP Caching Headers

Posted March 22nd, 2010 in PHP

Yesterday I looked at how to control browser caching with Apache's mod_expires and today look at how to set the caching/expiry time with headers in PHP to either make sure the resulting data is never cached by the browser, or is cached for a set amount of time.

Read more »

Logging errors with PHPLogging errors with PHP

Posted March 18th, 2010 in PHP

PHP has several settings for logging errors; in this post I will look at the log_errors and error_log settings which control whether errors should be logged and where to.

Read more »

PHP PDO DSN Connection StringPHP PDO DSN Connection String

Posted March 15th, 2010 in PHP

PHP's Data Objects, known as PDO, are well covered in the PHP online documentation here but the format of the DSN connection string is covered individually for each driver so I've summarised them here in this post for quick reference.

Read more »

Setting 503 Service Temporarily Unavailable headers with Apache .htaccessSetting 503 Service Temporarily Unavailable headers with Apache .htaccess

Posted March 14th, 2010 in Apache and PHP

When temporarily taking down a website to perform maintenance, it's a good idea to return a "503 Service Temporarily Unavailable" header so search engines know to come back later. This post shows how to set this header using an Apache .htaccess file, and also how to show a response page to users with PHP so they know to try again later.

Read more »

Disabling PHP short tags in an Apache .htaccess fileDisabling PHP short tags in an Apache .htaccess file

Posted March 11th, 2010 in Apache and PHP

PHP code in a script is commonly delimited by opening <?php and closing ?> tags but there are also the older short open tags like this <? There are instances where you may need to disable short tags as shown in this post and using an Apache .htaccess file.

Read more »

Handling errors when connecting to a database using PHP PDOHandling errors when connecting to a database using PHP PDO

Posted March 8th, 2010 in PHP

PHP's PDO database abstraction class offers a better way to connect to databases than the mysql_* etc style functions, or using a 3rd party database library. This post looks at handle errors when connecting and a follow up post later this week will look at how to check for errors when running individual queries after a connection has been successfully established.

Read more »

Exiting from within a PHP exceptionExiting from within a PHP exception

Posted March 4th, 2010 in PHP

This is the final post in my series about PHP exceptions and looks at how when an exception occurs, script execution may continue depending on how the exception is handled.

Read more »

Randomly ordering data with MySQL with a random value columnRandomly ordering data with MySQL with a random value column

Posted March 3rd, 2010 in MySql and PHP

It's possible to order data randomly with MySQL using ORDER BY RAND() or doing a count on the table and then using LIMIT to choose a random offset. However neither of these are suitable for dealing with large tables with many rows. In this post I present an alternative to these but it does require modifications to the table and additional business logic and is still not perfect.

Read more »

Load JSON data with jQuery, PHP and MySQLLoad JSON data with jQuery, PHP and MySQL

Posted March 2nd, 2010 in Javascript, MySql and PHP (Updated December 1st, 2010)

This post shows how to populate a select box based on the value of the another, by getting JSON data with jQuery from a PHP script that gets the data from a MySQL database.

Read more »

Converting an array to JSON data with PHPConverting an array to JSON data with PHP

Posted March 1st, 2010 in PHP

PHP's json_encode function converts a PHP variable into a JSON string which can then be used in Javascript, for example using jQuery's JSON functions. This is easy to do and I'll be combining the two together in tomorrow's post to show how to fetch data from a MySQL database with PHP into Javascript via JSON.

Read more »

Fetching data using PHP and PDO with bound placeholdersFetching data using PHP and PDO with bound placeholders

Posted February 26th, 2010 in MySql and PHP

This post shows how to fetch data from a MySQL database using PHP's PDO library with bound placeholders. This is a fairly basic tutorial and the functions used in it will be used in a post tomorrow titled "Load JSON data with jQuery, PHP and MySQL".

Read more »

Catch mutiple exception types with PHPCatch mutiple exception types with PHP

Posted February 25th, 2010 in PHP (Updated March 4th, 2010)

PHP's try..catch can be used to catch multiple exception types. If the try block could cause one of several different exceptions they can each be handled separately with their own catch section.

Read more »

Get the filename extension with PHPGet the filename extension with PHP

Posted February 22nd, 2010 in PHP

I've covered how to get the filename and directory name from a full path with PHP before and did include a section which happened to include how to get the filename extension as well, but I continue to find myself unable to remember the name of the function so I've put that part of the previous post into this new one with a title specific to finding the extension.

Read more »

Extend PHP's exception objectExtend PHP's exception object

Posted February 18th, 2010 in PHP (Updated February 25th, 2010)

PHP's Exception object can be extended (just as any class can be that is not declared final) which means different exception types can be thrown that handle the exception differently.

Read more »

PHP shebangPHP shebang

Posted February 15th, 2010 in PHP

I've posted a number of times in the past about how it is possible to run PHP scripts from the command line and here dedicate a post to showing how a PHP script can be run by adding a shebang line and running it as if it were any other command.

Read more »

Replace error reporting with exception handlers with PHPReplace error reporting with exception handlers with PHP

Posted February 11th, 2010 in PHP (Updated February 25th, 2010)

As part of a series of posts about PHP exception handling, this post looks at how to make regular errors use exception model. Normally only the newer object-oriented extensions throw exceptions but it is possible to make all errors throw an exception instead using set_error_handler.

Read more »

Extract the first paragraph text from a web page with PHPExtract the first paragraph text from a web page with PHP

Posted February 8th, 2010 in PHP

This post looks at how to extract the first paragraph from an HTML page using PHP's strpos and substr functions to find the location of the first <p> and </p> tags and get the content between them.

Read more »

Catch uncaught exceptions with PHPCatch uncaught exceptions with PHP

Posted February 4th, 2010 in PHP (Updated February 25th, 2010)

This is the third in a series of posts about exception handling in PHP and looks at how to specify a default exception handler. The default handler is called for any exceptions that occur which are not enclosed in a try..catch block.

Read more »

An alternative to ORDER BY RAND() for MySQLAn alternative to ORDER BY RAND() for MySQL

Posted February 3rd, 2010 in MySql and PHP (Updated February 23rd, 2010)

I've posted previously about how to randomly order a resultset with MySQL using RAND() but the issue with RAND() is it will be inefficient on large tables because each row needs to have the random number calculated before the resultset can be ordered. This post looks at an alternative which requires two queries but will be much more efficient for large tables.

Read more »

How to escape variables with PHP PEAR DB with bound placeholdersHow to escape variables with PHP PEAR DB with bound placeholders

Posted February 1st, 2010 in PHP

A week ago I looked at how to escape a string for use with a SQL query using the PHP PEAR DB escapeSimple function. This is useful for embedding a variable directly into a SQL query string but it can be a lot easier to use bound placeholders instead and let PEAR DB do all the escaping.

Read more »

PHP Exceptions - available informationPHP Exceptions - available information

Posted January 28th, 2010 in PHP (Updated February 25th, 2010)

This post is part of a series about PHP exceptions and exception handling; the first post gave a basic overview of how they work and this one shows the information that is available from the exception object when an exception is caught.

Read more »

How to escape variables with PHP PEAR DBHow to escape variables with PHP PEAR DB

Posted January 25th, 2010 in PHP

When using the PHP PEAR DB database abstraction library it is important to escape variables just as it is when using the native database function calls. If you don't know why this is then do a search using your favourite search engine for "sql injection". This post shows the PEAR DB way of escaping variables.

Read more »

PHP ExceptionsPHP Exceptions

Posted January 21st, 2010 in PHP (Updated February 25th, 2010)

PHP has an exception model that works with the newer object oriented extensions but not with the older internal functions (those use the older style error reporting instead). This is the first in a series of posts on this blog about PHP exceptions; this one gives a basic overview.

Read more »

Get the value of a PHP constant dynamicallyGet the value of a PHP constant dynamically

Posted January 18th, 2010 in PHP

It is possible to get the value of a PHP constant dynamically using the constant() function. It takes a string value as the parameter and returns the value for the constant if it is defined.

Read more »

How to use an associative array with PHP's str_replace functionHow to use an associative array with PHP's str_replace function

Posted January 14th, 2010 in PHP

If you are a PHP developer, I'm sure you know the str_replace function for replacing strings and are probably aware that you can pass an array of strings as the search strings and an array as the replacements. What this post looks at is a way of using a single associative array instead of two arrays, which makes dealing with a large number of replacements much more maintainable in your code.

Read more »

Create an array containing a range of numbers or letters with PHPCreate an array containing a range of numbers or letters with PHP

Posted January 11th, 2010 in PHP

Here's another PHP function I discovered the other day which you may find useful. It's called "range" and is used to create an array containing a range of numbers or letters. This is different from array_fill which creates an array with a number of the same elements and which I covered in my" Intialise an array in PHP with default values" post.

Read more »

Get Apache to parse .html files as PHPGet Apache to parse .html files as PHP

Posted January 10th, 2010 in Apache and PHP

When PHP is installed in Apache files with the .php extension are interpreted as PHP scripts. It is possible to make any file extension be parsed as PHP including .html.

Read more »

Change the email body character set with PEAR Mail_MimeChange the email body character set with PEAR Mail_Mime

Posted January 7th, 2010 in PHP

The PHP PEAR Mail Mime library makes it easy to create multi part emails with attachments and alternate plain text and HTML messages. I recently needed to change the character set from the default iso-8859-1 to utf-8 to render some special unicode characters and show in this post how to do this.

Read more »

NuSphere PhpEd, Smarty {literal} blocks and syntax highlightingNuSphere PhpEd, Smarty {literal} blocks and syntax highlighting

Posted January 4th, 2010 in PHP

I recently upgraded to NuSphere PhpEd 5.9 and noticed that some {literal} blocks in a Smarty template did not have any syntax highlighting. I am not sure if this was the case previously for the same section of code but worked out the location of the {literal} tags needed to be moved for syntax highlighting to work.

Read more »

Backtracing with PHP Part 2Backtracing with PHP Part 2

Posted December 24th, 2009 in PHP

A week ago I looked at how to do a backtrace with PHP using the debug_backtrace function which returns an array containing a lot of information, and the debug_print_backtrace function which provides more concise information but always sends it to standard output. In this post I show how to capture the information fromdebug_print_backtrace into a string and an alternative method using the Exception object.

Read more »

Output buffering with PHPOutput buffering with PHP

Posted December 21st, 2009 in PHP

Output is not buffered by default with PHP and the contents of the script is sent to the browser in chunks as it is created. PHP's output buffering functions buffer the output giving control over when content is sent, allowing it to be compressed and allowing a mixture of headers and content to be coded without getting those "Cannot modify header information - headers already sent" error messages.

Read more »

Backtracing with PHP Part 1Backtracing with PHP Part 1

Posted December 17th, 2009 in PHP (Updated December 24th, 2009)

If you need to debug a PHP script but do not have debugging tools at hand in your IDE or similar, an easy way to try to see what's happening and what functions are being called is to use PHP'sbacktracing tools. It can be useful also to include a backtrace when sending or logging errors that have occured on a production website.

Read more »

Multiple variable assignment with PHPMultiple variable assignment with PHP

Posted December 14th, 2009 in PHP

This post shows how it is possible to assign multiple variables with the same value with PHP. This can be useful if initializing multiple variables with the same initial value or if needing to make multiple copies of a value and then manipulate each separately.

Read more »

Get the directory name and filename from a full path name with PHPGet the directory name and filename from a full path name with PHP

Posted December 10th, 2009 in PHP

It's easy to get the filename and directory name components of a full path name with PHP using the dirname(), basename() and pathinfo() functions. The latter also contains the filename extension.

Read more »

PHP's nowdoc stringsPHP's nowdoc strings

Posted December 4th, 2009 in PHP

PHP has heredoc syntax like other programming languages to interpolate variables into large string blocks (which I've covered in an earlier post). In PHP 5.3.0 a new string delimiter was introduced called "nowdoc" which works in the same was as heredoc but acts like a single quoted string, so no variable interpolation or parsing is done.

Read more »

PHP: Write and append to files with file_put_contentsPHP: Write and append to files with file_put_contents

Posted November 30th, 2009 in PHP

The PHP file_put_contents() function is a useful shortcut for dumping a string into a file (compared with using fopen, fputs etc). By default it will create a new file if it does not exist, or overwrite the file if it does exist. Recently I re-read the documentation for this function and discovered it is also possible to append to a file with file_put_contents.

Read more »

Resolving relative URLs to absolute in PHPResolving relative URLs to absolute in PHP

Posted November 26th, 2009 in PHP

When scraping content using the PHP Simple HTML DOM Parser it is useful to resolve relative URLs in a page to absolute URLs for downloading additional web pages or images. I do this using the url_to_absolute library byNadeau Software Consulting and show how to do this here, along with a minor fix which needs to be done to their code.

Read more »

Get all variables assigned to Smarty - Part 2Get all variables assigned to Smarty - Part 2

Posted November 23rd, 2009 in PHP

A few weeks back I posted how to get all the variables assigned to Smarty using the get_template_vars() function and in this post expand the example and show how to get just one assigned variable instead of everything.

Read more »

Find all anchor tags in a page with PHP and the Simple HTML DOM ParserFind all anchor tags in a page with PHP and the Simple HTML DOM Parser

Posted November 16th, 2009 in PHP

This post shows how to download a web page and find all the link anchor tags in the page using PHP and the Simple HTML DOM Parser which has a jQuery like syntax selector.

Read more »

Copying an object in PHP with cloneCopying an object in PHP with clone

Posted November 10th, 2009 in PHP

Objects in PHP are assigned by reference, so copying an object with the = operator will result in a second variable referencing the same object and not an actual copy. Enter PHP's clone function which creates a shallow copy of the object.

Read more »

Extract query string into an associative array with PHPExtract query string into an associative array with PHP

Posted November 2nd, 2009 in PHP (Updated August 16th, 2010)

A little while back I posted how to extract the domain, path, etc from a url with PHP and in this follow up post show how to extract the query string into an associative array using the parse_str function.

Read more »

Using + to merge arrays with PHPUsing + to merge arrays with PHP

Posted October 26th, 2009 in PHP

I've been working at a new job and the interesting thing when working with other people's code is you often learn a heap of stuff you didn't already know. A couple of weeks ago I came across a way to merge arrays in PHP with the + operator, instead of using the array functions (e.g. array_merge) so share this here.

Read more »

Get the Feedburner original link with PHPGet the Feedburner original link with PHP

Posted October 8th, 2009 in PHP

Many websites use Feedburner to serve their RSS feed. The link from the Feedburner feed to the article is a Feedburner URL which then redirects to the original URL. The original URL is still contained in the XML for the feed in the element named <feedburner:origLink> and this can be parsed out using PHP's SimpleXML library, but it's not quite as simple as referring to ->feeburner:origLink because this will not work.

Read more »

Access an element's attributes with PHP's SimpleXML extensionAccess an element's attributes with PHP's SimpleXML extension

Posted October 5th, 2009 in PHP

The PHP SimpleXML extension makes it easy to work with XML files by creating an object from the XML structure. To access an element's attributes, use the property() method for that element.

Read more »

Type hinting with PHPType hinting with PHP

Posted October 1st, 2009 in PHP

PHP has supported type hinting for parameter functions from version 5.0 for objects and from version 5.1 for arrays. Type hinting means the function specifies what type the parameter must be and if it is not of the correct type an error will occur. Type hinting is not supported for other types, e.g. for strings and integers.

Read more »

Extract domain, path etc from a full url with PHPExtract domain, path etc from a full url with PHP

Posted September 28th, 2009 in PHP (Updated August 16th, 2010)

PHP's parse_url function makes it easy to extract the domain, path and other useful bits of information from a full URL. This can be useful for a variety of purposes, such as when spidering content from a website and needing to extract particular pieces of information from the links in the page.

Read more »

Get all variables assigned to Smarty - Part 1Get all variables assigned to Smarty - Part 1

Posted September 24th, 2009 in PHP

I've been working with the PHP templating engine Smarty at a new job and needed to be able to dump a list of variables that had been assigned to Smarty for debugging purposes. This quick post shows how to dump the variables in your PHP code.

Read more »

PHP's heredoc stringsPHP's heredoc strings

Posted September 21st, 2009 in PHP

PHP has heredoc syntax similar to other programming and scripting languages which allow multi line strings containing variables to be easily assigned to variables or echoed. This post looks at how to format a heredoc block in PHP and some of the rules.

Read more »

Get the headers sent from the browser with PHPGet the headers sent from the browser with PHP

Posted September 17th, 2009 in PHP

I recently needed to be able to see what headers the browser sent to the web server with PHP for testing purposes. This is possible using the apache_request_headers() function but it only works if PHP is run on Apache as a module. This post shows usingapache_request_headers() and also an alternative when PHP is run as a CGI. I believe this second method works for lighttpd but have no idea if it works for IIS.

Read more »

Extract images from a web page with PHP and the Simple HTML DOM ParserExtract images from a web page with PHP and the Simple HTML DOM Parser

Posted September 14th, 2009 in PHP (Updated August 23rd, 2011)

After posting about how to get the meta tags from an HTML web page with PHP was asked how to get the images from an HTML page with PHP like how Facebook does when a link is posted. This post looks at how to get the image URLs from a page using the Simple HTLM DOM Parser library and in a later post I'll look at how to download the images and make thumbnails.

Read more »

Get meta tags from an HTML file with PHPGet meta tags from an HTML file with PHP

Posted September 10th, 2009 in PHP

While researching some functions for a PHP article I'm writing I came across the get_meta_tags() function and decided to write a quick post about it.

Read more »

PHP for loops and counting arraysPHP for loops and counting arrays

Posted September 7th, 2009 in PHP

It's well known that calling count($array) in a for loop in PHP is slower than assigning the count to a variable and using that variable in the for loop instead. However until recently, I wasn't aware that the assignment to a variable can be done in the for loop itself and share this here in this post.

Read more »

410 "Gone" with PHP410 "Gone" with PHP

Posted September 3rd, 2009 in PHP

If a resource has been removed from a website, will not be available again and no forwarding address is available then it should return a 410 "Gone" HTTP status. This post explores the 410 status compared with a 404 "Not Found" and 301"Moved Permanently" and shows how to do a 410 with PHP.

Read more »

Validating an IP address with PHP's filter_var functionValidating an IP address with PHP's filter_var function

Posted August 31st, 2009 in PHP

PHP's filter_var function can validate if an IP address is valid and can further validate if it is an IPv4 IP, IPv6 IP, or not within the private or reserved ranges. This post shows some examples using filter_var.

Read more »

Get the number of days in a month with PHPGet the number of days in a month with PHP

Posted August 27th, 2009 in PHP

This post shows how to get the number of days in a month with PHP by specifying the year and month. This can be useful when generating a calendar application without having to manually code in the number of days each month has, and not having to worry about the number of days in February which varies on leap years.

Read more »

PHP CURL and CookiesPHP CURL and Cookies

Posted August 24th, 2009 in PHP

PHP's CURL functions make it easy to download content from websites. Sometimes you need to be able to manage cookies set from the site the data is coming from. This is done using the CURLOPT_COOKIEJAR and CURLOPT_COOKIEFILE options as shown in this post.

Read more »

PHP GeoIP functions throw notices if the IP address is not foundPHP GeoIP functions throw notices if the IP address is not found

Posted August 20th, 2009 in PHP

I recently posted how to do geo targeting with PHP with the GeoIP functions but discovered when testing something today that PHP throws an E_NOTICE notice error if the IP address does not exist in the database.

Read more »

Setting the http referer with PHP CURLSetting the http referer with PHP CURL

Posted August 17th, 2009 in PHP

The PHP CURL functions use the libcurl library to allow you to connect to various servers and different protocols. If the http referer string is not explicitly defined then nothing will be sent to the web server, but there may be times when you need to pass this along with your request.

Read more »

PHP geo targeting with the geoip functionsPHP geo targeting with the geoip functions

Posted August 13th, 2009 in PHP

The PHP GeoIP library makes it easy to look up country codes and names from an IP address. It's not enabled/installed by default so you need to install it before you can access these functions. I've already posted about how to do this with Debian and other Linux distros will be similar.

Read more »

How to enable the PHP GeoIP functions on Debian 5How to enable the PHP GeoIP functions on Debian 5

Posted August 13th, 2009 in Linux/Unix/BSD and PHP

The geoip_* PHP functions utilise the GeoIP library from Maxmind to geolocate IP addresses to country names. These functions are not enabled by default and this post shows how to enable them for PHP 5 on Debian 5.

Read more »

Setting the user agent with PHP CURLSetting the user agent with PHP CURL

Posted August 10th, 2009 in PHP

The PHP CURL functions use the libcurl library to allow you to connect to various servers and different protocols. If the user agent string is not explicitly defined then nothing will be sent to the web server. If you are scraping a website with CURL for whatever reason, there may be times you need to specify the useragent string and this post shows how to do it.

Read more »

PHP: Class XsltProcessor not foundPHP: Class XsltProcessor not found

Posted August 9th, 2009 in PHP

A PHP install on Debian 5 by default does not include the Xslt extension which means the following error will occur if trying to use the XsltProcessor class: " Fatal error: Class 'XsltProcessor' not found...". This post shows how to install the extension on Debian 5.

Read more »

Submitting a form post with PHP and CURLSubmitting a form post with PHP and CURL

Posted August 7th, 2009 in PHP

The PHP CURL functions use the libcurl library to allow you to connect to various servers and different protocols. This post shows how to make an HTTP POST with PHP and CURL passing several form fields. This can be useful for testing your own web forms, connecting to APIs that require POST data and so on.

Read more »

Get and modify the error reporting level in PHPGet and modify the error reporting level in PHP

Posted July 23rd, 2009 in PHP

PHP's error_reporting() function allows a script to check what the current error reporting level is and/or modify it. I wouldn't normally recommend changing the error reporting level programatically, but there may be times when it's needed. The nice thing is it's easily possible to get the current level, change it, and then set it back to what it was previously.

Read more »

PHP's unserialize function and E_NOTICEPHP's unserialize function and E_NOTICE

Posted July 20th, 2009 in PHP (Updated July 23rd, 2009)

PHP has the serialize and unserialize functions for converting data into a storable value (for example being able to store an array in a database field). An issue with the unserialize function is that it will issue an E_NOTICE error if the data is notunserializeable. This post looks at how to prevent the notices from being displayed if you have error reporting at a level that will show notices.

Read more »

Using PHP's scandir() function to find files in a directoryUsing PHP's scandir() function to find files in a directory

Posted July 17th, 2009 in PHP

There are a number of ways to find the files in a directory with PHP. I've covered opendir() readdir() and closedir() and glob() in previous posts and now look at scandir().

Read more »

Combine and minify Javascript files with PHPCombine and minify Javascript files with PHP

Posted July 16th, 2009 in Javascript and PHP

If you're using a Javascript library like jQuery it's likely you'll end up with many Javascript files that need to be included in each page request. Ideally these should be combined into a single file and minified to cut down on page load time. This post shows how to use jsmin-phpto combine multiple Javascript files into a single minified file.

Read more »

Get data for a single page from the Google Analytics APIGet data for a single page from the Google Analytics API

Posted July 14th, 2009 in PHP

The Google Analytics API has a filters feature which allows you to filter the data in a variety of ways, including filtering by URL. This means that you can get specific metrics (e.g. pageviews etc) for a single page from the GA API.

Read more »

PHP email validation using the Zend FrameworkPHP email validation using the Zend Framework

Posted July 9th, 2009 in PHP

My last PHP post looked at how to do email validation with filter_var() which is available from PHP 5.2.0. However if the server your website is being hosted on has an earlier version of PHP then you can't use filter_var(). This post looks at how to use the Zend Framework to validate email addresses instead, if you are using the Zend Framework.

Read more »

PHP email validation with filter_varPHP email validation with filter_var

Posted July 6th, 2009 in PHP (Updated November 9th, 2012)

There's no longer any need in PHP to create your own regular expressions to try to validate an email address; simply use filter_var() instead. This is available from PHP 5.2.0.

Read more »

Using PHP's glob() function to find files in a directoryUsing PHP's glob() function to find files in a directory

Posted July 2nd, 2009 in PHP

A couple of weeks ago I posted how to read through a directory with PHP using the opendir() readdir() and closedir() functions and now look at the glob() function. glob() returns the filenames into an array and supports pattern matching so it can be very easy to find e.g. jpg images in a particular directory.

Read more »

Sending a username and password with PHP file_get_contents()Sending a username and password with PHP file_get_contents()

Posted June 29th, 2009 in PHP

Last week I looked at how send a username and password with PHP CURL. Using CURL is useful because you can examine the return information to see if the request was successful etc, but if your hosting provider doesn't have CURL for PHP enabled then you can still attempt to get the file by using file_get_contents and passing the authentication as part of the $context parameter.

Read more »

Prevent a view rendering with the Zend FrameworkPrevent a view rendering with the Zend Framework

Posted June 25th, 2009 in PHP

The front controller of the Zend Framework will render a view by default but it's possible to disable this automatic rendering should you need to, for example if making an Ajax call which sends some JSON data instead of an HTML template.

Read more »

Sending a username and password with PHP CURLSending a username and password with PHP CURL

Posted June 22nd, 2009 in PHP

CURL and PHP combined can be really useful for getting data from websites, connecting to APIs (such as the Google Analytics API) and so on. Sometimes you may need to connect to a website that is password protected so this post looks at how to pass the username and password with PHP and CURL.

Read more »

Reading through a directory with PHPReading through a directory with PHP

Posted June 18th, 2009 in PHP

PHP's opendir() readdir() and closedir() are used for reading the contents of a directory (there's also glob() and scandir() but I'll cover those in later posts). Combined with functions like is_file() is_dir() and is_link() and you can easily build up a directory tree or process files etc.

Read more »

Autoloading with PHP's SPL libraryAutoloading with PHP's SPL library

Posted June 15th, 2009 in PHP

I read Rafael Dohms's post " SPL: a hidden gem " a few days ago and learned of a better alternative to PHP's __autoload function using SPL instead and thought I'd share this here along with some more details about the spl_autoload_register() and spl_autoload_functions() functions.

Read more »

Google Analytics API PHP Class data method parametersGoogle Analytics API PHP Class data method parameters

Posted June 12th, 2009 in PHP

This post documents the parameters that can be passed to the data() method of my PHP class for interfacing with the Google Analytics API. You can read more about my class here as well as download it along with an example script.

Read more »

PHP's trim() functionPHP's trim() function

Posted June 11th, 2009 in PHP

PHP's trim() function has a second parameter which allows a list of characters to trim to be passed in. This allows characters other than (or instead of) the default space character to be trimmed from a string. It works for trim(), rtrim() and ltrim().

Read more »

Calculating a page's bounce rate with the Google Analytics APICalculating a page's bounce rate with the Google Analytics API

Posted June 11th, 2009 in PHP

I had an email a couple of days ago from someone asking me how to calculate the bounce rate for a page using my PHP Class for the Google Analytics API.

Read more »

Paging through result data from the Google Analytics API PHP ClassPaging through result data from the Google Analytics API PHP Class

Posted June 8th, 2009 in PHP

I had a query the other day about paging through Google Analytics API data using my PHP Class; Google allows a maximum of 1000 records to be returned at a time per request so you need to loop until there's no more data, requesting 1000 records at a time starting from offset 1001, 2001 etc.

Read more »

Get the included files with PHPGet the included files with PHP

Posted June 4th, 2009 in PHP

PHP's get_included_files() function returns an array containing a list of included files by your script, including the script itself. This post looks at the filenames returned in the array and corrects a couple of errors in the PHP documentation.

Read more »

Articles about how to use PHP's IMAP FunctionsArticles about how to use PHP's IMAP Functions

Posted June 1st, 2009 in PHP (Updated January 11th, 2012)

This is a summary post with links through to all the posts on my blog where I've looked at various functions using PHP's IMAP functions to download mail and extract attachments etc.

Read more »

List of PHP email librariesList of PHP email libraries

Posted June 1st, 2009 in PHP

I'm going to write a series about how to send and receive email using various different PHP email libraries to show the differences between them and what's required for each to work. This post is a list of PHP mail libraries that I know of and will be reviewing/writing code for over the coming weeks. If you know of any others you'd like me to look at please send me an email and I'll add them to the list.

Read more »

Using filters with the Google Analytics API and PHPUsing filters with the Google Analytics API and PHP

Posted May 31st, 2009 in PHP (Updated July 14th, 2009)

The Google Analytics API allows filtering to be done on the result data before it is fetched so you could, for example, only get data for visitors from the United States. This post shows how to format the filters field in PHP and also how to use my Google Analytics API PHP Class with filters.

Read more »

Google Analytics API PHP Class - Get most popular pagesGoogle Analytics API PHP Class - Get most popular pages

Posted May 30th, 2009 in PHP

The following shows example usage to get the most popular pages from Google Analytics using my PHP class for the GA API.

Read more »

Google Analytics API PHP Class - Updates May 28th 2009Google Analytics API PHP Class - Updates May 28th 2009

Posted May 28th, 2009 in PHP

I've published an update to my Google Analytics API PHP Class today which adds better support for filtering, and have added some filtering examples and more documentation to the example.php file.

Read more »

Set PHP configuration options in an Apache virtualhostSet PHP configuration options in an Apache virtualhost

Posted May 28th, 2009 in PHP

I've previously looked at how to set PHP configuration options in an Apache .htaccess file which allows you to change PHP_INI_PERDIR or PHP_INI_ALL settings but notPHP_INI_SYSTEM. All three of these settings types can be modified in an Apache virtualhost's settings.

Read more »

Show PHP configuration options for a selected extensionShow PHP configuration options for a selected extension

Posted May 25th, 2009 in PHP

Following up an earlier post about PHP's ini_get_all function to show PHP's configuration options, this post shows how to get just the config for a particular extension.

Read more »

Google Analytics API PHP Class - Updates May 22nd 2009Google Analytics API PHP Class - Updates May 22nd 2009

Posted May 22nd, 2009 in PHP

I've made some updates to my Google Analytics API PHP Class today and posted the updated class and example files. The changes are documented here.

Read more »

Rounding numbers with PHPRounding numbers with PHP

Posted May 21st, 2009 in PHP

I have previously looked at rounding numbers with MySQL and Javascript and in this post look at rounding numbers with PHP using the round() ceil() floor() number_format() and s/printf() functions.

Read more »

Google Analytics API PHP Class - Q&A May 21st 2009Google Analytics API PHP Class - Q&A May 21st 2009

Posted May 21st, 2009 in PHP

I've had some more questions about my Google Analytics API PHP Class by email so am posting the information relating to these questions here to help other people out who may have the same issues.

Read more »

PHP's ini_get_all functionPHP's ini_get_all function

Posted May 18th, 2009 in PHP

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.

Read more »

Who's using my Google Analytics API PHP Class?Who's using my Google Analytics API PHP Class?

Posted May 17th, 2009 in PHP (Updated October 10th, 2009)

I've had a lot of feedback and responses to my Google Analytics API PHP Class and decided to add a page here to list people who are using it. If you are using my class and would like to be listed here then please send me an email and I will add you.

Read more »

Log PHP errors with log_errors and error_logLog PHP errors with log_errors and error_log

Posted May 14th, 2009 in PHP

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.

Read more »

Google Analytics API PHP Class - Q&A May 13th 2009Google Analytics API PHP Class - Q&A May 13th 2009

Posted May 13th, 2009 in PHP (Updated May 15th, 2009)

I had some questions in an email about my Google Analytics API PHP class last night and have posted them here to help other people too.

Read more »

Automatically append or prepend files in a PHP scriptAutomatically append or prepend files in a PHP script

Posted May 11th, 2009 in PHP

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.

Read more »

Looping through the Google Analytics API PHP class dataLooping through the Google Analytics API PHP class data

Posted May 5th, 2009 in PHP

Thanks for Jim Snyder from www.net-netanalytics.com for pointing out my examples were lacking the information to show how to loop through the resulting data from my Google Analytics API PHP Class. I have now update the examples file and also include the information about how to loop through the data in this post. You can always download themost recent version of my PHP class here.

Read more »

Google Analytics PHP API: Getting data without a dimensionGoogle Analytics PHP API: Getting data without a dimension

Posted May 4th, 2009 in PHP

My Google Analytics API PHP class was initially developed assuming that a dimension would always be supplied but it doesn't actually need to be, so I modified it to deal with no dimension and present an example here.

Read more »

Get the Google Analytics profile id from the accounts listGet the Google Analytics profile id from the accounts list

Posted April 30th, 2009 in PHP

Just a quick post about an easy way to get the profile id for a Google Analytics account using my PHP Class. The ->load_accounts() function loads the accounts into an associative array which you can then access from ->accounts. The profile id is stored in there.

Read more »

Google Analytics API PHP Class Update April 30th 2009Google Analytics API PHP Class Update April 30th 2009

Posted April 30th, 2009 in PHP

Thanks to the several people who emailed me with questions etc about my PHP class for accessing the Google Analytics API. The most common issue was when making a request for data and nothing came back. I've addressed this issue by adding some error triggering in the code and also a note in the example about the correct formatting for the profile id.

Read more »

Can't connect to the Google Analytics APICan't connect to the Google Analytics API

Posted April 29th, 2009 in PHP (Updated April 29th, 2009)

I had an email this morning about my Google Analytics API PHP class which said "I'm trying to get your google API class working in my application, it's failing at logon at the moment" so I had a look at the possible reasons for failure and present these here.

Read more »

The Google Analytics API and PHP: A seriesThe Google Analytics API and PHP: A series

Posted April 28th, 2009 in PHP (Updated December 16th, 2009)

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.

Read more »

Converting Google Analytics API XML data into an array with PHPConverting Google Analytics API XML data into an array with PHP

Posted April 28th, 2009 in PHP

This post updates my Google Analytics API PHP class again with a new method which can be used to get data from any dimension and metric and return it as an associative array. The full class, which I will continue to update over the next few days, can be downloaded here.

Read more »

Load the Google Analytics API accounts list with PHPLoad the Google Analytics API accounts list with PHP

Posted April 27th, 2009 in PHP (Updated April 28th, 2009)

After Google made an API available for Google Analytics the other day I started a series of posts about how to get analytics data with PHP and CURL. Today's post extends the class I've already posted by adding a function to get the list of accounts you have access to. This enables you to get the ID needed to pass to further API calls.

Read more »

PHP class for using the Google Analytics APIPHP class for using the Google Analytics API

Posted April 23rd, 2009 in PHP (Updated April 28th, 2009)

Just quickly following up my post from earlier on today where I looked at how to log into the Google Analytics API using PHP and CURL using Username/Password Authentication I wrapped the login code up into a class with methods for logging in and then calling API functions.

Read more »

Log into the Google Analytics API using PHP and CURL using Username/Password AuthenticationLog into the Google Analytics API using PHP and CURL using Username/Password Authentication

Posted April 23rd, 2009 in PHP (Updated April 28th, 2009)

Google have finally made an API available for Google Analytics although it's currently in beta and the specs are subject to change. I've been playing around this morning logging in usingClientLogin Username/Password Authentication with PHP and CURL and show how to do this here. In future posts I'll look at how to actually use the API but this will get us all started for now.

Read more »

Google Analytics API LaunchedGoogle Analytics API Launched

Posted April 23rd, 2009 in Miscellaneous Postings and PHP

Google have finally launched an API for Google Analytics, rendering my tutorial series about how to get Analytics data via email somewhat redundant. However despite that I'm pleased they've done this as it makes accessing data a lot easier.

Read more »

PHP's getdate() functionPHP's getdate() function

Posted April 20th, 2009 in PHP

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.

Read more »

Fix the "call to undefined function curl_init" error in PHP on DebianFix the "call to undefined function curl_init" error in PHP on Debian

Posted April 17th, 2009 in Linux/Unix/BSD and PHP

If you call the curl_init function in PHP and do not have the curl module installed you will get the error message "Fatal error: Call to undefined function curl_init() in /path/to/script.php on line XY". This post shows how to install the PHP curl module on Debian Linux and the instructions should also work on all Debian derived distros such as the Ubuntu family.

Read more »

Set PHP configuration options with an Apache .htaccess fileSet PHP configuration options with an Apache .htaccess file

Posted April 16th, 2009 in Apache and PHP (Updated May 28th, 2009)

PHP has a large number of configuration option which can be set in the php.ini file, Apache <virtualhost> blocks, .htaccess files and ini_set(). This post looks at how to set PHP configuration options with Apache's .htaccess files.

Read more »

Sending a CSV file to the web browser with PHPSending a CSV file to the web browser with PHP

Posted April 13th, 2009 in PHP

In the past I've written about how to save data as a CSV file using PHP, MySQL queries and mysqldump and in this post show how to send the results of this data to a web browser setting the headers correctly with PHP so the browser gives you a "save as" dialog instead of displaying it on the page. The headers also include the filename which is supplied as the default in the save as dialog.

Read more »

Create a CSV file from MySQL with PHPCreate a CSV file from MySQL with PHP

Posted April 12th, 2009 in MySql and PHP

There are a couple of ways to export data from MySQL to a CSV file (refer to my using mysqldump to save data to CSV files and export data to CSV from MySQL posts for details) but neither of them supports adding a header row to the CSV which contains the column names. This post looks at how to export the data from MySQL into a CSV file with PHP including a header row.

Read more »

Fix the "call to undefined function ImageCreateFromPNG" error in PHP on DebianFix the "call to undefined function ImageCreateFromPNG" error in PHP on Debian

Posted April 10th, 2009 in Linux/Unix/BSD and PHP

If you call the ImageCreateFromPNG function (and similar image processing functions) in PHP and do not have the GD module installed you will get the error message "Fatal error: Call to undefined function ImageCreateFromPNG()" error message. This post shows how to install the PHP GD module on Debian Linux and the instructions should also work on all Debian derived distros such as the Ubuntu family.

Read more »

Listing MySQL tables with PHPListing MySQL tables with PHP

Posted April 9th, 2009 in MySql and PHP

This post shows how to use the MySQL "SHOW TABLES FROM" SQL query to get a list of tables using PHP. This list could either be stored to an array or echoed out to web browser, command line etc.

Read more »

Get a list of IP addresses for a domain with PHPGet a list of IP addresses for a domain with PHP

Posted April 6th, 2009 in PHP

On Thursday I looked at how to get a domain name's IP address with PHP using the gethostbyname() function. However some domains resolve to multiple IP addresses so this followup post looks at how to get a list of IP addresses for a domain in PHP using the gethostbynamel() function.

Read more »

Apache does not log HTTP status set with PHP header when using mod_rewrite in .htaccess filesApache does not log HTTP status set with PHP header when using mod_rewrite in .htaccess files

Posted April 5th, 2009 in Apache and PHP (Updated April 6th, 2009)

I discovered something rather annoying the other day relating to setting HTTP response codes with PHP's header() function, Apache's mod_rewrite and associated webserver logging. If anyone knows of a solution to the issue I have discovered below I'd love to know it.

Read more »

Get a domain name's IP address with PHPGet a domain name's IP address with PHP

Posted April 2nd, 2009 in PHP

It's easy to get the IP address for a domain name using PHP's gethostbyname() and gethostbynamel() functions. This post looks at some examples of using thegethostbyname() function in PHP to get a single IP address for a hostname.

Read more »

Find unread messages using PHP IMAPFind unread messages using PHP IMAP

Posted March 30th, 2009 in PHP (Updated February 8th, 2011)

Having reached the conclusion of my series on getting Google Analytics data by email I had an enquiry from someone asking how to find only the unread email messages using PHP IMAP. This is simple enough to do and can be done either when looping through the messages or using the imap_search function.

Read more »

Deleting messages with PHP IMAP and GmailDeleting messages with PHP IMAP and Gmail

Posted March 26th, 2009 in PHP

My last PHP post looked at how to delete email messages using PHP's IMAP functions. This is straight forward on a regular POP3 or IMAP mail server but deleting a message when connected to Gmail just removes it from the inbox and it's still available in "All Mail" rather than being moved into the trash. This post looks at how to move an email into Gmail's trash with PHP IMAP.

Read more »

Install APC for PHP on Debian 5 LennyInstall APC for PHP on Debian 5 Lenny

Posted March 26th, 2009 in Linux/Unix/BSD and PHP

I have recently moved from hosting on a CentOS box to Debian and needed to install PHP's APC opcode cache on it. I've posted about how to do this before on a CentOS box which is a very manual process and now add this post to install APC on Debian which is much easier.

Read more »

Deleting messages with PHP IMAPDeleting messages with PHP IMAP

Posted March 23rd, 2009 in PHP

I've been writing a series about sending Google Analytics data by email and then processing the emails with PHP's IMAP functions. Once the email has been processed you'll probably want to delete the emails from the mailbox afterwards so this email looks at how to delete emails using PHP's IMAP functions.

Read more »

Parsing Google Analytics data with PHP - XML filesParsing Google Analytics data with PHP - XML files

Posted March 22nd, 2009 in PHP

This post shows how to extract data from a XML email attachment from data sent by Google Analytics with PHP. Previously I have covered how to get the data from CSV files and TSV files and now it's time for dealing with XML.

Read more »

Force reload of updated CSS and Javascript files with unique filenamesForce reload of updated CSS and Javascript files with unique filenames

Posted March 20th, 2009 in Apache, HTML and CSS, Javascript and PHP

When a CSS or Javascript file is changed the visitor's browser needs to get the latest copy of the file to reflect the changes, but it will have been cached and may cause rendering or functionality issues depending on the changes. To force reloading of the CSS and Javascript file the files should be renamed each time they are changed; this can be automated by using PHP to add the timestamp of the file into the filename.

Read more »

Parsing Google Analytics data with PHP - TSV filesParsing Google Analytics data with PHP - TSV files

Posted March 19th, 2009 in PHP

This post shows how to extract data from a TSV (tab separated values) email attachment from data sent by Google Analytics with PHP. This post is virtually identical to the previous post in this series which looked at how to do the same for CSV files, except in this case we use a \t delimiter for the str_getcsv function.

Read more »

Parsing Google Analytics data with PHP - CSV filesParsing Google Analytics data with PHP - CSV files

Posted March 16th, 2009 in PHP

This post shows how to extract data from an email attachment from data sent by Google Analytics with PHP. I've covered how to download and extract attachments with PHP's IMAP functions in previous posts and am now coming to the end of this series finally showing how to get the data out of the attachments.

Read more »

PHP's str_getcsv functionPHP's str_getcsv function

Posted March 16th, 2009 in PHP

While writing my series on extracting data from Google Analytics emails with PHP I discovered PHP has a new function called str_getcsv which works the same way as fgetcsv but extracts CSV data from a string instead of from a file.

Read more »

Install PHP IMAP on DebianInstall PHP IMAP on Debian

Posted March 16th, 2009 in Linux/Unix/BSD and PHP

 If you are getting the "Fatal error: Call to undefined function imap_open()" error in PHP when using the IMAP functions then they are not installed with your installation of PHP. This post looks at how to install the PHP IMAP functions on Debian and should also work for Ubuntu/Kubuntu/etc and other Debian derived Linux distros.

Read more »

Downloading Google Analytics data attachments with PHP IMAPDownloading Google Analytics data attachments with PHP IMAP

Posted March 15th, 2009 in PHP

This post is part of a series about having Google Analytics data sent by email and then downloading and parsing the data with PHP. Having already set up the automatic sending of data by email this post puts together all the work of the previous posts and actually downloads the attachment by looping through the email messages in the inbox and looking for the specific message to download. The next three posts in the series will then look at how to extract the data from a CSV, TSV or XML formatted attachment.

Read more »

Function to extract email attachments using PHP IMAPFunction to extract email attachments using PHP IMAP

Posted March 15th, 2009 in PHP (Updated January 11th, 2012)

This is a supplementary post in my series about having Google Analytics data sent by email and then downloading and parsing the data with PHP. This post simply contains a PHP function for extracting all the attachments of an email using the PHP IMAP functions into an array.

Read more »

Parsing Google Analytics data with PHP: A SeriesParsing Google Analytics data with PHP: A Series

Posted March 13th, 2009 in PHP (Updated May 30th, 2009)

At the start of 2009 I added a "Recent Posts" section to the sidebar navigation of this blog and decided I'd update it using data from Google Analytics. Unfortunately Analytics doesn't have an API to get data but does have a function for sending data by email on regular basis either as a TSV, CSV, XML or PDF attachment.

Therefore a somewhat spordaic series of posts began appearing on this blog showing how to get Google Analytics data by email and use PHP's IMAP functions to read through a mailbox and extract data from the attachments.

Read more »

PHP IMAP: Looping through messages to find a specific subjectPHP IMAP: Looping through messages to find a specific subject

Posted March 5th, 2009 in PHP (Updated March 23rd, 2009)

This post is part of a series about downloading email using the PHP IMAP functions. The ultimate goal of the series is to show how to export Google Analytics data by email, and then use PHP to connect to the mail server, find and download the appropriate message and then load the data into a database. This post looks at how to look for a specific email message using the PHP IMAP functions.

Read more »

Defining a custom error handler for the PHP ADODB Lite database libaryDefining a custom error handler for the PHP ADODB Lite database libary

Posted March 2nd, 2009 in PHP

ADODB Lite is a database abstraction library for PHP. Custom error handlers can be set up for ADODB Lite which will be triggered whenever an error occurs in SQL queries or when attempting to connect to the database. This post looks at how to set up a customer error handler for the ADODB Lite database library.

Read more »

Open a mailbox other than the INBOX with PHP IMAPOpen a mailbox other than the INBOX with PHP IMAP

Posted February 26th, 2009 in PHP

This post is part of an on-going series on this blog about connecting to IMAP mailboxes with PHP, ultimately showing how to download and parse reports from Google Analytics. When logging into an IMAP server with PHP the default mailbox is used - usually the INBOX. This post looks at how to list the mailboxes for the IMAP account and then how to connect to one of the other mailboxes.

Read more »

Using PHP IMAP functions to download email from GmailUsing PHP IMAP functions to download email from Gmail

Posted February 23rd, 2009 in PHP (Updated November 16th, 2010)

A couple of weeks back I posted how to use the PHP IMAP functions to download email from an IMAP server. This post looks at how to do the same but downloading IMAP mail from Gmail, which you need to connect to on a different port and use SSL. Earlier today I posted how to enable IMAP mail access in Gmail so you'll need to ensure that's done first.

Read more »

Command line PHP script to make a backup copy of a MySQL tableCommand line PHP script to make a backup copy of a MySQL table

Posted February 19th, 2009 in PHP

On Sunday I looked at how to create a copy of a MySQL table with a PHP script and this post looks at how to do the same, but running the PHP script from the command line and passing in the table to copy from and to on the command line.

Read more »

How to tell if a PHP constant has been defined alreadyHow to tell if a PHP constant has been defined already

Posted February 16th, 2009 in PHP

You can define constants in PHP with the define() function and can check if a constant has already been defined with the defined() function. This post looks at both functions with some examples.

Read more »

PHP script to make a backup copy of a MySQL tablePHP script to make a backup copy of a MySQL table

Posted February 15th, 2009 in MySql and PHP

Yesterday I looked at how to copy a table with MySQL using some SQL queries. This post looks at how to automate the process with a PHP script saving you having to type in and adjust queries each time you want to back up a table.

Read more »

Extracting attachments from an email message using PHP IMAP functionsExtracting attachments from an email message using PHP IMAP functions

Posted February 9th, 2009 in PHP

This post is part of an ongoing series which aims to show how to extract data from Google Analytics using its scheduled email reports system. I have already looked at how to send Google Analytics data by email, and how to use the PHP IMAP functions to download email. I will also look at using other PHP libraries to download email and attachments, but for now this post looks at how to extract email attachmentsusing the PHP IMAP functions.

Read more »

Add additional HTML code after the first </p> tag in PHPAdd additional HTML code after the first </p> tag in PHP

Posted February 8th, 2009 in PHP

I recently made some minor layout changes to my blog including the positioning of the advertising from the top of each article to after the first paragraph. In this post I share the PHP code used to add some additional HTML code after the first closing </p> tag in a page's content.

Read more »

Using PHP IMAP functions to download emailUsing PHP IMAP functions to download email

Posted February 5th, 2009 in PHP (Updated August 6th, 2010)

This post looks at how to connect to a POP or IMAP mailbox using PHP's IMAP mail functions and retrive the number of messages in the mailbox, the message headers and body, and then to delete the message.

Read more »

Install PHP IMAP on CentOSInstall PHP IMAP on CentOS

Posted February 5th, 2009 in Linux/Unix/BSD and PHP

If you are getting the "Fatal error: Call to undefined function imap_open()" error in PHP when using the IMAP functions then they are not installed with your installation of PHP. This post looks at how to install the PHP IMAP functions on CentOS and should also work for Red Hat Enterprise Linux (RHEL), Fedora and other derived Linux distros.

Read more »

Running PHP scripts as shell scriptsRunning PHP scripts as shell scripts

Posted February 2nd, 2009 in PHP

As well as running PHP scripts via a web server such as Apache, you can also run PHP scripts from the command line (it's also possible to write GUI apps with PHP using PHP-GTK, but I'll maybe look at that another time). This post looks at the two ways you can run a PHP script from a *nix based computer (Linux, Unix, BSD, OSX) and the single way you can do it from Windows.

Read more »

Get the first sentence with PHPGet the first sentence with PHP

Posted January 29th, 2009 in PHP (Updated May 31st, 2010)

Sometimes you may need to get the first sentence from a block of content for use as e.g. the meta description for a page. This post looks at how to get the first sentence using PHP.

Read more »

How to tell if it's an HTTPS request in PHPHow to tell if it's an HTTPS request in PHP

Posted January 26th, 2009 in PHP

This post looks at how to tell whether or not the request being made to the web server is an HTTPS request with PHP. This works for Apache - I'm not sure if the method used here works for other web server types.

Read more »

Using the is_callable function in PHPUsing the is_callable function in PHP

Posted January 22nd, 2009 in PHP

The PHP function is_callable() tests to see if a function or class method can be called, and solves an issue with the method_exists() function which will return true for all methods regardless of whether or not they can actually be called.

Read more »

Review: Mastering phpMyAdmin 2.11 for Effective MySQL ManagementReview: Mastering phpMyAdmin 2.11 for Effective MySQL Management

Posted January 21st, 2009 in MySql and PHP

The post has a look at the book "Mastering phpMyAdmin 2.11 for Effective MySQL Management" by Marc Delisle (who is one of the phpMyAdmin developers) and available to buy from the Packt Publishing website, where you can buy it as a hard copy book or an eBook. I am not affiliated with Marc Delisle or Packt Publishing in any way, but was supplied a free copy of the eBook to review.

Read more »

Using the Zend_Registry in PHPUsing the Zend_Registry in PHP

Posted January 19th, 2009 in PHP

The Zend Framework has a component called the Zend_Registry which allows you to store data into a sort of global space which lasts the duration of the script. Once saved to the registry the data is available throughout the application. This post shows how to save some data to the registry and then retrieve it.

Read more »

How to check if a class method exists in PHPHow to check if a class method exists in PHP

Posted January 16th, 2009 in PHP

Last week I looked at how to see if a function exists in PHP and this time will look at how to check if a class method exists in PHP.

Read more »

How to tell if it's an AJAX request in PHPHow to tell if it's an AJAX request in PHP

Posted January 12th, 2009 in PHP

Some of the upcoming jQuery posts I will be publishing will be making AJAX requests so I thought it fitting to post how to tell if the incoming request is an AJAX request in PHP for the PHP programmers out there. This is useful if your script handles both AJAX and non-AJAX requests and you need to know which sort it is.

Read more »

How to check if a function exists in PHPHow to check if a function exists in PHP

Posted January 9th, 2009 in PHP

You can test if a function exists in PHP with the function_exists() function, which returns true if the function exists and false if it does not. You can then take appropriate action to include the necessary library files or create the function etc.

Read more »

FCKeditor &nbsp; after capital letters and colonsFCKeditor &nbsp; after capital letters and colons

Posted January 7th, 2009 in FCKEditor and PHP

I use FCKEditor on my content driven websites to write the content. In version 2.6.3 I have found that the editor inserts &nbsp; characters after capital letters and the colon character, and I don't want this behaviour. This post shows a server-sided solution to the problem using PHP.

Read more »

Changing the timezone with PHPChanging the timezone with PHP

Posted December 31st, 2008 in PHP

Since PHP 5.1.0 it has been possible to change the default timezone that PHP uses using the date.timezone configuration, which can be set for the entire server in php.ini or httpd.conf, on a virtualhost by virtualhost basis, or using the ini_set() function. This post looks at how to change the timezone in PHP using the ini_set function.

Read more »

PHP list of php.ini directivesPHP list of php.ini directives

Posted December 30th, 2008 in PHP

PHP allows you to set a variety of configuration settings in either the web server's configuration (e.g. Apache's httpd.conf or .htaccess) and using the ini_set function. The PHP manual contains a complete list of php.ini directives and this short post is simply my place of bookmarking the list, as I often need to refer to it.

Read more »

RSS with PHP - Don't forget to set the Content-TypeRSS with PHP - Don't forget to set the Content-Type

Posted December 27th, 2008 in PHP

Just a quick little post to remind that PHP/Apache sets the content-type header by default to text/html. If you are serving other content, such as an RSS feed, you need to remember to change the content type to the appropriate format.

Read more »

Google Analytics Screen Widths with PHP (Internet Explorer)Google Analytics Screen Widths with PHP (Internet Explorer)

Posted December 24th, 2008 in PHP

A week ago I looked at copying and pasting the screen resolution data from Google Analytics and parsing it to get just the screen widths and percentages with a PHP script using Firefox. The copy-paste format is different for Internet Explorer so this followup postmodifies the script for IE.

Read more »

Google Analytics Screen Widths with PHP (Firefox)Google Analytics Screen Widths with PHP (Firefox)

Posted December 17th, 2008 in PHP

Google Analytics has screen resolution information but groups them by both width and height. I was wanting to know the percentage of visitors by width so created a PHP script to parse text copied from the Analytics page and sum up the percentage by screen width.

Read more »

Set the content encoding type with PHP headersSet the content encoding type with PHP headers

Posted December 13th, 2008 in PHP

Although you can set content type in the HTML <head> section of a web page the web server can also send the content type as one of its headers, and it can cause unexpected consequences when rendering a page in a browser. This post looks at how to set the content encoding type header with PHP.

Read more »

Check if a class exists with PHPCheck if a class exists with PHP

Posted December 11th, 2008 in PHP

PHP has the class_exists() function to check if a class has already been defined. You may need to take action depending if a class exists or not, and need to watch out for "gotchas" when also using __autoload().

Read more »

Method chaining with PHPMethod chaining with PHP

Posted December 7th, 2008 in PHP (Updated January 5th, 2009)

Having used the Zend Framework on a couple of projects and spent a lot of time reading the documentation I discovered the use of method chaining. This post looks at how to use method chaining in PHP.

Read more »

Validating numbers with PHPValidating numbers with PHP

Posted November 25th, 2008 in PHP

Last week David Walsh posted about validating numeric values and digits with PHP on his excellent blog. I posted my own comments about his particular post but they never appeared so I decided to post a better response here.

Read more »

5 PHP job and programming experience tips5 PHP job and programming experience tips

Posted November 20th, 2008 in PHP

I've had a couple of people email me recently asking for tips about looking for PHP work in New Zealand and getting programming experience etc. This post looks at 5 ideas I had for them. Note some are specific to New Zealand but use local job websites and mailing listsinstead of the ones suggested here if you're from another country.

Read more »

Get the class name and parent class name in PHPGet the class name and parent class name in PHP

Posted November 19th, 2008 in PHP

Sometimes you need to be able to get the class name or parent class name of an object in PHP to do something conditionally etc. This post looks at how to do this.

Read more »

Zend Framework 1.7.0 releasedZend Framework 1.7.0 released

Posted November 18th, 2008 in PHP

The Zend Framework 1.7.0 has been released and is available for immediate download. This release fixes 288 bugs introduces many new components and features. It can be downloaded from the Zend Framework Downloads Page and read more about this release on Matthew Weier O'Phinney's blog.

Read more »

How to use PHP's __autoload functionHow to use PHP's __autoload function

Posted November 12th, 2008 in PHP (Updated June 15th, 2009)

PHP introduced the __autoload() function in version 5 which is called whenever the code tries to use a class that has not yet been defined. You simply put some code into __autoload() to include the appropriate class file and don't have to bother about manually including those files. This post looks at how to do this with examples.

Read more »

CodeIgniter loading models error when changing web hostCodeIgniter loading models error when changing web host

Posted November 9th, 2008 in PHP

I've been in the process of moving a website that uses the CodeIgniter PHP framework from one of my servers to another provider's server and kept getting"Fatal error: Call to a member function on a non-object" type errors when trying to use some of my models. This post looks at what was causing the issue.

Read more »

Using hash algorithms in PHPUsing hash algorithms in PHP

Posted November 7th, 2008 in PHP

PHP has a number of hashing algorithms available for creating hash values of files and strings. A hash is a non-reversible fixed length string which has a number of applications, such as storing a password in a database in a way that can not be read. This post looks at how to show the available hashes in PHP and how to use the hash() function to generate a hash value.

Read more »

PHP fatal libpng error: zlib errorPHP fatal libpng error: zlib error

Posted November 4th, 2008 in PHP (Updated January 19th, 2012)

While working with some image functions in PHP I changed the output image from JPEG to PNG (from the ImageJPEG to ImagePNG functions) and got the error message "gd-png: fatal libpng error: zlib error". This post looks at the cause of the error and the solution.

Read more »

404 Page not found with PHP404 Page not found with PHP

Posted October 29th, 2008 in PHP

A PHP script will normally return a 200 HTTP code to the browser which means the page has been successfully retrieved but it's possible to also return other status codes when redirecting (e.g. doing a permanent redirect) or a 404 to indicate a page has not been found. This post looks at how to do a 404 page not found error with PHP.

Read more »

Check if a PHP script is already runningCheck if a PHP script is already running

Posted October 28th, 2008 in PHP (Updated October 29th, 2008)

If you have long running batch processes with PHP that are run by cron and you want to ensure there's only ever one running copy of the script, you can use the functions getmypid() and posix_kill() to check to see if you already have a copy of the process running. This post has a PHP class for checking if the script is already running.

Read more »

PHP SoapClient "Unable to parse URL" errorPHP SoapClient "Unable to parse URL" error

Posted October 23rd, 2008 in PHP

While testing a web service I was creating in PHP using the PHP SoapClient and SoapServer classes I got the error "Unable to parse URL" from a WSDL file generated using Zend Studio. This post looks at the error and how to fix it.

Read more »

Hide selected databases in phpMyAdminHide selected databases in phpMyAdmin

Posted October 21st, 2008 in MySql and PHP

A few days ago I posted how to hide the information schema in phpMyAdmin and of course using the advice in that post you can hide any database you want. The hide_db phpMyAdmin configuration option is a regular expression so you can use it to hide several databases, and this post looks at how to do this.

Read more »

Hide the information schema in phpMyAdminHide the information schema in phpMyAdmin

Posted October 11th, 2008 in MySql and PHP

When you log into phpMyAdmin you can only see the databases for which you have access rights, as well as the information_schema database. It is possible to hide this database if you want to. This post looks at how to hide the information_schema database in phpMyAdmin.

Read more »

Intialise an array in PHP with default valuesIntialise an array in PHP with default values

Posted October 7th, 2008 in PHP

PHP has a useful function for initialising an array with default values called array_fill(). This post looks at how to use the array_fill function and the output of these arrays with the print_r function.

Read more »

Change the user agent string in PHPChange the user agent string in PHP

Posted October 2nd, 2008 in PHP

Most of PHP's file functions can be used to open local files as well as remote files via HTTP etc. By default the user agent string passed when making an HTTP requestis an empty string but it is possible in PHP to change the user agent string to something else. This post looks at how to do this.

Read more »

Return information from PHP print_r instead of displaying itReturn information from PHP print_r instead of displaying it

Posted September 30th, 2008 in PHP

print_r is a useful PHP function for displaying the values of an array or object when debugging etc. Having been a PHP programmer since the days of PHP 3.x I didn't realise this function had added the capability to return the information as well as print it from PHP 4.3.0 and only discovered this in the last few days. This post gives a brief overview of PHP's print_r function.

Read more »

New Zealand daylight savings starts on SundayNew Zealand daylight savings starts on Sunday

Posted September 26th, 2008 in Linux/Unix/BSD and PHP

The dates that New Zealand daylight savings starts and ends changed in New Zealand last year and it caused a lot of issues with many servers and desktop computers which hadn't had updates made available in time for the change. Daylight savings starts this Sunday in New Zealand on Sunday September 28th and I thought it a good idea to check the servers I manage are all correct and ready to handle the changeover.

Read more »

Work out if a number in PHP is odd or evenWork out if a number in PHP is odd or even

Posted September 23rd, 2008 in PHP

Sometimes you might need to know if a number is odd or even, and this post looks at how to determine if a number is odd or even in PHP using the modulus arithmetic operator.

Read more »

Fix the mbstring PHP extension not found error in phpMyAdminFix the mbstring PHP extension not found error in phpMyAdmin

Posted September 18th, 2008 in PHP (Updated February 24th, 2010)

phpMyAdmin is a web based front end to MySQL written in PHP. It likes to have the mbstring extension loaded if using a multi byte character set and will display warnings when you first log into phpMyAdmin if it is not available. This post looks at the error message and how to install the mbstring extension for PHP on CentOS / Red Hat Enterprise Linux using yum.

Read more »

Update PHP from the command line with YUMUpdate PHP from the command line with YUM

Posted September 16th, 2008 in PHP

It is important to keep software up to date on your computer and web servers. I manage a few webservers which run Apache/PHP/MySQL on CentOS, a Red Hat Enterprise Linux derivitive, and use YUM to install software and keep it up to date. This post looks how you would just do an update to PHP using YUM on CentOS.

Read more »

Optimize tables in MySQL automatically with PHPOptimize tables in MySQL automatically with PHP

Posted September 7th, 2008 in MySql and PHP

In previous posts I looked at how to optimize a MySQL table from the MySQL command line interface and from phpMyAdmin by using the optimize [tablename] command to free up unused space. In this post I will look at how to do this with a PHP script which could be run periodically to optimise all non-optimal MySQL tables.

Read more »

PHP CLI counter for long running processesPHP CLI counter for long running processes

Posted August 29th, 2008 in PHP

I've been doing a reasonable amount of PHP CLI (command line interface) programming recently for getting stuff from log files and converting large numbers of images. Some of these processes can some quite a while to run, sometimes as long as several hours, so it can be useful to know roughly how far through the process it is.This post looks at how to output a counter to the command line from PHP which replaces itself on each iteration.

Read more »

Sending email with Zend_MailSending email with Zend_Mail

Posted August 23rd, 2008 in PHP

The Zend Framework is a PHP framework with many individual components that do not require you to use the whole framework. In this post I will look at how to send an emailusing the Zend Framework's Zend_Mail component.

Read more »

Using the FCKEditor HTML Editor with PHPUsing the FCKEditor HTML Editor with PHP

Posted August 20th, 2008 in FCKEditor and PHP

FCKeditor is an in-browser WYSIWYG HTML editor and I use it on a number of websites including in the blog admin for this website. This post looks at how to put FCKeditor into a web page using PHP. In future posts I will look at some of the other functions and features of FCKeditor.

Read more »

PHP Date ConstantsPHP Date Constants

Posted August 16th, 2008 in PHP

When writing my "Get a list of all available constants with PHP" post I discovered there are a number of usful date format constants in PHP which can be used with the date() function. (Refer to my "Formatting Dates with PHP" post for more details about the PHP date function). This post looks at these constants and how to use them with the date function. Please note that these constants have only been present in PHP since 5.1.1.

Read more »

Type casting with PHPType casting with PHP

Posted August 10th, 2008 in PHP

PHP is a loosely typed language and assigns types to variables depending what is assigned to it. Variables coming from get/post and cookies etc are generally cast as strings rather than other types and there are often other times when you need to specifically cast a type in PHP as e.g. an integer. This post looks at how to type cast in PHP and some of the results than can come about from type casting.

Read more »

303 redirect with PHP303 redirect with PHP

Posted July 31st, 2008 in PHP

When you submit a form using a web browser the script processing the form often redirects after it has done its work to a thank you page (or similar). The response type people usually use when coding with PHP is a 302 redirect because it's the default used when issuing a Location: header. The problem with this is on a page refresh the browser is likely to submit the form again. Instead you can use a 303 redirect to prevent the form being submitted again. This post looks at what a 303 response code / redirect is and how to send one with PHP.

Read more »

Image headers with PHPImage headers with PHP

Posted July 22nd, 2008 in PHP

If you ever need to send an image file with PHP from the web server to the web browser you need to add an additional header using the header() function so the browser knows it's an image and not regular HTML. This post looks at the headers you need to use.

Read more »

Get a list of all available constants with PHPGet a list of all available constants with PHP

Posted July 17th, 2008 in PHP

PHP has the function get_defined_constants() which allows you to get a list of all the available constants in an array. This post looks at how to use the get_defined_constants() function and example output from it.

Read more »

Get a list of all available classes with PHPGet a list of all available classes with PHP

Posted July 10th, 2008 in 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.

Read more »

Get an image size with PHPGet an image size with PHP

Posted July 9th, 2008 in PHP

PHP has a function called getimagesize() for getting the width and height from an image. I'm always forgetting the name of the getimagesize() function so I decided to write a post about it and showing some examples and that way maybe I'll remember in the future...

Read more »

Get a list of all available functions with PHPGet a list of all available functions with PHP

Posted July 3rd, 2008 in PHP

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

Read more »

List compiled modules with the PHP CLIList compiled modules with the PHP CLI

Posted June 29th, 2008 in PHP

The PHP CLI (Command Line Interface) has a number of flags which can be passed to it for executing PHP scripts, getting information about your PHP install and so on. This post looks at how to get a list of the modules compiled into the PHP CLI. Note that depending on the way your distribution/package has compiled PHP, the list of modules available for the webserver and the CLI may be different.

Read more »

JpGraph Error Can't access PHP_SELF, PHP global variableJpGraph Error Can't access PHP_SELF, PHP global variable

Posted June 27th, 2008 in PHP

One of the sites I work on uses JpGraph to generate graphs for their reports. A few months ago we moved the site from an old server with PHP 4 to a new server with PHP 5 and started getting the error "JpGraph Error: Can't access PHP_SELF, PHP global variable". This post looks at the error and a couple of possible solutions to it.

Read more »

Command line arguments for the PHP CLICommand line arguments for the PHP CLI

Posted June 19th, 2008 in PHP

The PHP command line interface or CLI allows you to run PHP scripts from the command line. It also has a number of flags that can be passed to it which allow you to see which modules are available, do a syntax check on a file, view PHP information etc. This post gives a basic list of the command line arguments available for the PHP CLI and in later posts I will look at some of the options in more detail.

Read more »

Command line arguments with a PHP CLI scriptCommand line arguments with a PHP CLI script

Posted June 15th, 2008 in PHP

PHP has the getopt() function for getting options or command line arguments from a CLI PHP script. This provides a simple way to get values from the command line like e.g. "-a foo". This post looks at how to do this. More details can be found in the PHP getopt() manual page.

Read more »

PHP function to check if a MySQL table existsPHP function to check if a MySQL table exists

Posted June 14th, 2008 in MySql and PHP

Yesterday I posted how to check if a MySQL table exists using show tables or the MySQL information schema. Today I am posting a simple PHP function I created which you can use to test if a table exists.

Read more »

PHP is not showing any error messagesPHP is not showing any error messages

Posted June 10th, 2008 in PHP

Help! There are errors in my PHP code and there are no error messages being displayed. I've even set error_reporting to E_ALL and still PHP is not displaying the errors. How do I debug it? How do I show the errors? This post looks at the very simple answer to these questions.

Read more »

phpMyAdmin "operation could take a long time" messagephpMyAdmin "operation could take a long time" message

Posted June 4th, 2008 in PHP

In phpMyAdmin in some of my databases when I am browsing a table and click the button to take me to last page of records I get a Javascript message telling me "This operation could take a long time. Proceed anyway?" with "OK" and "Cancel" buttons. This post looks at why the message pops up and how you can control when it appears.

Read more »

Set the default font size for phpMyAdminSet the default font size for phpMyAdmin

Posted May 17th, 2008 in PHP

phpMyAdmin is a web based administrative tool for the MySQL database server. After logging in to phpMyAdmin there's a drop down box to select the font size as a percentage which always defaults to 100% and is too big for my liking. After changing the value, the font size is remembered as a cookie so the next time you log in the font size chosen is remembered. However the font size cookie drops off eventually and when logging into a phpMyAdmin that I haven't logged into for a while I find it annoying having to change the font size each time. This post looks at how to change the default phpMyAdmin font size.

Read more »

Database error handling with the Zend FrameworkDatabase error handling with the Zend Framework

Posted May 11th, 2008 in PHP (Updated May 22nd, 2012)

When running database queries in the past, I have used my own database abstraction libraries, Code Igniter, the PEAR database library, ADODB and ADODB Lite. Each of these easily allows error handling by having a function called in the event of a database error occuring. I have recently started using the Zend Framework, but there doesn't appear to be this capability of automatic error handling. This short post looks at how to capture and handle database errors with the Zend Framework.

Read more »

How to tell if it's a leap year with PHPHow to tell if it's a leap year with PHP

Posted April 29th, 2008 in PHP

PHP contains a useful date function which can be used to determine if the current year or a specific year is a leap year. This post looks at how to use the date function to do this.

Read more »

Using the HTTP_REFERER variable with PHPUsing the HTTP_REFERER variable with PHP

Posted April 18th, 2008 in PHP (Updated August 16th, 2010)

When a web browser moves from one website to another and between pages of a website, it can optionally pass the URL it came from. This is called the HTTP_REFERER, and this post looks at how to use this variable with PHP.

Read more »

Zend Framework Controller Router exampleZend Framework Controller Router example

Posted April 12th, 2008 in PHP

The first MVC framework I used was Code Igniter but I've decided to give the Zend Framwork a go because I like their approach to use what you need, and after some studying of the controllers and view functionality those parts do more or less exactly what I want. There are ways to add additional routes to the controllers but I couldn't work out initially how to inject them into the controller from the Zend Framwork documentation. This post shows the original example from the Zend Framework documentation and then a more full example which I constructed using other sources.

Read more »

phpMyAdmin prevent popup window for query editingphpMyAdmin prevent popup window for query editing

Posted April 10th, 2008 in PHP

phpMyAdmin by default opens a popup window when you click the "Edit" link underneath a query. I personally prefer to not have a popup window open and this post looks at how to change the default behaviour.

Read more »

Allowed memory size exhausted when installing a PECL moduleAllowed memory size exhausted when installing a PECL module

Posted March 21st, 2008 in PHP

When attempting to install the timezonedb PECL module on one of the CentOS servers I manage, I got the following error message:

# pecl install timezonedb
downloading timezonedb-2007.11.tgz ...
Starting to download timezonedb-2007.11.tgz (180,439 bytes)
..........................done: 180,439 bytes

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 92160 bytes) in /usr/share/pear/PEAR/Builder.php on line 313

This post looks at how to install a PECL module a different way.

Read more »

Correcting the PHP timezoneCorrecting the PHP timezone

Posted March 16th, 2008 in PHP

The end of daylight savings in New Zealand has been changed from Sunday March 16th (today) to Sunday April 6th. Last week I looked out how to check the daylight savings dates will be applied correctly on Linux, but now that it's actually the day itself it turns out that while the operating system is using the correct date, PHP is not due to PHP5 maintainin its own internal timezone database. This post looks at how to temporarily correct the solution until it's fixed in the distro's PHP builds.

Read more »

301 redirect with PHP301 redirect with PHP

Posted March 15th, 2008 in PHP

When you change the URL/URI of a page, a permanent redirection should be set up from the old address to the new address to let user-agents know where it can now be found. When using a web browser the redirection is usually seamless; for search engine bots they will now know to stop requesting the old page and instead request the new address in the future. This post looks at how to do this with PHP.

Read more »

Determine whether PHP is being run via HTTP or CLI - Follow UpDetermine whether PHP is being run via HTTP or CLI - Follow Up

Posted March 9th, 2008 in PHP

As a quick follow up to yesterday's post about how to determine whether PHP is being run via HTTP or CLI, I decided to do a quick post about where I found the values in the source code which are returned by the php_sapi_name() function and PHP_SAPI constant.

Read more »

Determine whether PHP is being run via HTTP or CLIDetermine whether PHP is being run via HTTP or CLI

Posted March 8th, 2008 in PHP

PHP can be run as a webserver module, as a CGI application or from the command line as a CLI script. There is both a function and a PHP constant which allows you to determine whether PHP is being run via HTTP or CLI. This post looks at the function and constant and the possible values, as determined in the PHP 5.2.5 source code.

Read more »

Create a file with a unique name with PHPCreate a file with a unique name with PHP

Posted February 28th, 2008 in PHP

The PHP function tempnam() creates a file with a unique name. This can be useful if you need to output some data into a temporary file for one reason or another, and the actual name of the file is not important.

Read more »

PHP Error Class 'XsltProcessor' not foundPHP Error Class 'XsltProcessor' not found

Posted February 13th, 2008 in PHP

If you get the following error message in PHP then it means you need to have the XSL extension installed. Obviously the /path/to/file.php will be the actual path and filename of the PHP script the error occured in, and the line number will be the actual line. The PHP manual says that "PHP 5 includes the XSL extension by default" but one of my CentOS 5 installations it didn't seem to be; the following post looks at how to install this extension on CentOS 5.

Fatal error: Class 'XsltProcessor' not found in /path/to/file.php on line 138

Read more »

Displaying PHP APC Cache InformationDisplaying PHP APC Cache Information

Posted February 9th, 2008 in PHP

APC is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code. I posted about how to install APC on Linux a couple of days ago, and will now look at the apc.php script which comes with APC and shows information about how much of the cache is being used, what files are being cached, the number of times they've been accessed etc.

Read more »

Install APC for PHP on LinuxInstall APC for PHP on Linux

Posted February 6th, 2008 in PHP (Updated November 5th, 2008)

APC is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code. What this means is that APC reads your PHP files, parses them into a more efficient binary format and then caches them in memory so that each request for your PHP files and PHP library files can be fed from the parsed cache. This will generally lead to a speed increase when serving a PHP site, especially one with a lot of library files. This post looks at how to install APC for PHP on Linux. The Linux distribution I used was CentOS 5, but it should be fairly similar for most distros.

Read more »

PHP error Call to undefined function ImageCreateFromPNGPHP error Call to undefined function ImageCreateFromPNG

Posted January 9th, 2008 in PHP

If you get the following error message in PHP then it means you need to have the PHP GD extension installed. Obviously the /path/to/file.php will be the actual path and filename of the PHP script the error occured in, and the line number will be the actual line.

Fatal error: Call to undefined function ImageCreateFromPNG() 
  in /path/to/file.php on line 379

You'll also get this error message using other functions such as ImageCreateFromJPEG() if the PHP GD library is not installed.

Read more »

Splitting a large Apache log file with PHPSplitting a large Apache log file with PHP

Posted January 4th, 2008 in PHP

A little while back I needed to split a large Apache log file (3.5GB) up into smaller pieces and wanted to break it up into several files, with one for each day of the month. I initially tried using "grep" on the command line but this proved to be too slow, and I needed to run it once for each day and month so it was going to take 92 times to run, extracting just one day at a time over the course of three months. I ended up writing a quick little PHP script which was able to split the 3.5GB file into 92 files, one for each day of each month in under 4 minutes.

 

Read more »

Get unique array values with PHPGet unique array values with PHP

Posted December 29th, 2007 in PHP

The PHP function array_unique() allows you to create a new array which contains only the unique values from the original array. This post looks at some examples of using the array_unique function.

Read more »

Using strtotime with PHPUsing strtotime with PHP

Posted December 21st, 2007 in PHP

The strtotime() function in PHP allows you to convert English text date time strings into UNIX timestamps. It is useful for converting database datetime strings into UNIX timestamps and also creating dates into the future or past based on the current time or relative to a date and time in the future or the past. This post looks at some examples of doing this.

Read more »

Formatting Dates with PHPFormatting Dates with PHP

Posted December 20th, 2007 in PHP

PHP has a really useful date() function for formatting dates from timestamps. When used in conjunction with strtotime() you can do some really quick and easy manipulation and formatting of dates.

Read more »

Triggering errors with PHPTriggering errors with PHP

Posted December 13th, 2007 in PHP

It is possible to trigger an error in PHP. This can be useful for debugging purposes, or if there is some condition which occurs in your PHP script which requires a PHP notice, warning or full error which causes the script to halt execution, and which would not be generated by PHP itself.

Read more »

MySQL Backups with a Command Line PHP ScriptMySQL Backups with a Command Line PHP Script

Posted December 9th, 2007 in MySql and PHP

I run a number of web servers with PHP and MySQL and have a PHP command line script that runs on a daily basis to back up MySQL databases using the mysqldump command. It would be possible to do this using a simple bash script as well, and I know I used to use a bash script in the past but for some reason switched it to PHP at some stage.

Read more »

PHP Magic ConstantsPHP Magic Constants

Posted December 8th, 2007 in PHP (Updated May 12th, 2010)

There are several PHP "magic constants" (or "magical contants") which can be useful for a variety of reasons. These magic constants aren't actually constants at all, but effectively behave like them, although the values change depending on the context.

Read more »

Replacing relative URLs with absolute URLs in PHPReplacing relative URLs with absolute URLs in PHP

Posted December 6th, 2007 in PHP

I've finally set up an RSS feed for this site and one of the things I needed to sort out was the use of URLs and image tags. All the anchor tags in this site are relative, and so are all the image sources. This isn't going to work in an RSS feed because it would mean none of the links would work, and the images would all be broken. Fortunately this is easy to fix with the use of PHP's string replacement functions.

Read more »

PHP Register Long Arrays HTTP_POST_VARSPHP Register Long Arrays HTTP_POST_VARS

Posted November 7th, 2007 in PHP

I have been in the process of moving my websites from a dedicated machine running Gentoo Linux to a VPS (Virtual Private Server) running CentOS 5. One of the ecommerce websites uses an old install of osCommerce which expects register globals and register_long_arrays on, otherwise things won't work very well.

While testing the site out on the new server, I couldn't work out why some of the form posts were working and some weren't. For example, on some pages I could add items to the shopping cart but on others I couldn't. I also couldn't click the form button to proceed to th checkout or update my basket: whenever I tried it kept showing me the same basket page again.

Read more »

Install the MSSQL module for PHP on CentOS 5Install the MSSQL module for PHP on CentOS 5

Posted November 4th, 2007 in PHP (Updated November 8th, 2007)

Unfortunately there is no pre-built module/extension for MSSQL for PHP in the Yum repositories for CentOS 5, so you need to build it yourself. It's a reasonably simple process, but you do need to have gcc and php-devel packages already installed (and a whole bunch of others which I'll list at the end of this post).

Read more »

PHP PEAR DB Code Completion in Zend StudioPHP PEAR DB Code Completion in Zend Studio

Posted November 2nd, 2007 in PHP

The PEAR DB library provides a database abstraction library for PHP, along with many other useful functions for running database queries. When using the PEAR DB library, if you want to enable code completion for these database functions, you need to add PHPDOC syntax to the top of your function calls.

Read more »

Javascript and CSS file timestamps with PHPJavascript and CSS file timestamps with PHP

Posted November 1st, 2007 in HTML and CSS, Javascript and PHP

Many websites I have worked on have frequently modified CSS style sheets and Javascript library files. In order to prevent Javascript errors or layout and style issues caused by web browsers caching these files, I used to rename the file for each revision, and then modify the name of the CSS or JS file in my PHP header include files. This article looks out how I now do this using the modified timestamp of the file.

Read more »

Java error executing Zend StudioJava error executing Zend Studio

Posted September 28th, 2007 in Applications and PHP (Updated September 28th, 2007)

After an upgrade from openSUSE 10.2 to 10.3 I wasn't able to run Zend Studio 5.5.0. I would click the icon to start it up and nothing would happen; even the splash screen would not appear. This post looks at the Java error the upgrade caused and the fix required to make it work again.

Read more »

PHP Error Class 'SoapClient' not foundPHP Error Class 'SoapClient' not found

Posted September 25th, 2007 in Apache and PHP

I've often found that something gets left out or forgotten when moving a website from an old server to a new install. I've just finished migrating one of my customer's sites to a new CentOS 5.0 install with Apache 2.2 and PHP 5.1.6, and there's one single PHP script in the site which uses the SoapClient class.

Naturally I'd forgotten to test this particular function until after the migration was complete, and was wondering why the script had failed. A quick look in the Apache error log file revealed the following error message: PHP Fatal error: "Class 'SoapClient' not found"

Read more »

PHP number_format() always returns 0PHP number_format() always returns 0

Posted September 22nd, 2007 in PHP (Updated September 28th, 2007)

After I inadvertently upgraded from openSUSE 10.2 to openSUSE 10.3RC1, I discovered that phpMyAdmin was showing all my database tables with 0 records in them. When I browsed the tables or ran a query that would return records then it would return them as expected. The screenshot shows a test database. You can see it shows 0 in the "Records" column, although it should show 3349 for the first table and 2 for the second.

Read more »

PHP echo with commas versus concatenationPHP echo with commas versus concatenation

Posted August 30th, 2007 in PHP

"echo" and "print" are used in PHP for writing strings out to a stream. I have always used concatenation when writing out multiple strings with echo or print, but recently discovered that echo accepts multiple arguments or parameters, comma separated like a regular function call. This post does some benchmarking to see which is faster: echo with commas, echo with concatenation, or print with concatenation.

Read more »

Process Forking with PHPProcess Forking with PHP

Posted March 4th, 2004 in PHP (Updated July 5th, 2011)

This article covers howto fork a child process using the PHP command line client and PHP process control functions. Several examples illustrate how to create child processes and make the parent wait until they have finished before continuing processing.

Read more »

Sablotron 1.01 Core Dumps with PHP and ApacheSablotron 1.01 Core Dumps with PHP and Apache

Posted February 12th, 2004 in Apache and PHP (Updated May 24th, 2005)

There is a known problem with the Sablotron 1.01 libraries on PHP and Apache which can cause pages to not load and core dumps on the server for some XML files when using Apache and PHP.

Read more »

phpMyAdminphpMyAdmin

Posted December 10th, 2003 in MySql and PHP (Updated February 24th, 2004)

phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL using a web browser and is one of the most active projects on Sourceforge.

Read more »

Errors Compiling PHP with SablotronErrors Compiling PHP with Sablotron

Posted November 30th, 2003 in PHP (Updated May 24th, 2005)

When compiling PHP with Sablotron there are errors which prevent PHP from compiling. This article covers what you need to do to enable PHP to compile correctly with Sabloton.

Read more »