<?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; properties</title>
	<atom:link href="http://plasmid.co.uk/tag/properties/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>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.420 seconds -->
