Writing PHP extensions for Windows–Introduction

This is the first in a series of articles covering writing and building PHP extensions for the Microsoft Windows operating system. Our target environment is IIS 5.1 running on a Windows XP PRO operating system. We are going to discuss installation, creating a compile environment and writing a simple extension.

What is PHP ?

PHP is a general purpose scripting language used for web development. It is implemented in major web servers (e.g Apache, IIS) and used in a lot of websites, for example the WordPress http://www.wordpress.com site is built using PHP. For more details on what PHP is, syntax, uses, history, installation please visit http://www,php.net

What is a PHP Extension ?

A PHP extension is a module containing a collection of exposed functions that extends and adds functionality to the PHP scripting language. These functions are written mostly in C and/or C++. Example is the mysql extension whose functions allow access to a MYSQL database.

function query($sqlStatement)
{
	// open connection
	if (!$this->open())
		return FALSE;

	$this->m_resultSet = mysql_query(
       $sqlStatement,
	      $this->m_connection);
	if (FALSE == $this->m_resultSet)
	  return FALSE;

	// initialize stats
	$this->m_countResults = mysql_num_rows(
	      $this->m_resultSet);
	$this->m_currentPosResultSet = 0;
	return TRUE;
}

In the code snippet listed above, mysql_query and mysql_num_rows are functions provided by the mysql PHP extension.

Reiterating our objective, we will write a simple extension containing one function which we are going to use in a PHP script. This extension will be hosted and executed on a Windows XP Pro IIS Server 5.1 Server. Simply, we are going to write something like a “mysql_query”.

Our Test Environment and Tools

Next Installation.

Advertisements

One thought on “Writing PHP extensions for Windows–Introduction

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s