<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Cormac&#8217;s php blog</title>
	<atom:link href="https://cormacscode.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://cormacscode.wordpress.com</link>
	<description>Web / internet development, mostly using php / mysql</description>
	<lastBuildDate>Tue, 12 Oct 2010 15:20:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cormacscode.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://s0.wp.com/i/buttonw-com.png</url>
		<title>Cormac&#8217;s php blog</title>
		<link>https://cormacscode.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://cormacscode.wordpress.com/osd.xml" title="Cormac&#039;s php blog" />
	<atom:link rel='hub' href='https://cormacscode.wordpress.com/?pushpress=hub'/>
	<item>
		<title>Practical example php implementation of the Observer pattern</title>
		<link>https://cormacscode.wordpress.com/2010/10/12/practical-example-php-implementation-of-the-observer-pattern/</link>
					<comments>https://cormacscode.wordpress.com/2010/10/12/practical-example-php-implementation-of-the-observer-pattern/#comments</comments>
		
		<dc:creator><![CDATA[cormacscode]]></dc:creator>
		<pubDate>Tue, 12 Oct 2010 13:13:48 +0000</pubDate>
				<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://cormacscode.wordpress.com/?p=155</guid>

					<description><![CDATA[Observer is a pattern where an object called the subject maintains a list of dependents (observers) and notifies them of any state changes. I implemented this recently to log changes to an Account object, and to notify the account holder if their account had expired &#8211; here&#8217;s the basics of the code, hopefully it&#8217;ll help [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Observer is a pattern where an object called the <em>subject</em> maintains a list of dependents (<em>observers</em>) and notifies them of any state changes. I implemented this recently to log changes to an Account object, and to notify the account holder if their account had expired &#8211; here&#8217;s the basics of the code, hopefully it&#8217;ll help someone else figure out how the pattern works</p>
<pre>&lt;?php
interface Observer
{
 public function update(Observable $subject);
} 

interface Observable
{
 public function attachObserver(Observer $dependent);
 public function detachObserver(Observer $dependent);
 public function notify();
}

class Account implements Observable
{
 public $status;
 private $_observers = array();

 public function __construct()
 {
  $this-&gt;attachObserver(new Logger());
  $this-&gt;attachObserver(new Mailer());
 }

 public function attachObserver(Observer $object)
 {
  $this-&gt;_observers[] = $object;
 }

 public function detachObserver(Observer $object)
 {
  foreach ($this-&gt;_observers as $index =&gt; $observer) {
   if ($object == $observer) {
    unset($this-&gt;_observers[$index]);
   }
  }
 }

 public function notify()
 {
  foreach ($this-&gt;_observers as $observer) {
   $observer-&gt;update($this);
  }
 }

 public function save()
 {
  <span style="text-decoration:line-through;">$this-&gt;notify($this);</span>
  $this-&gt;notify();
 }
}

class Logger implements Observer
{
 public function update(Observable $subject)
 {
 //Update status in log table
 echo "Updating status in log table.\n";
 }
}

class Mailer implements Observer
{
 public function update(Observable $subject)
 {
 switch (get_class($subject)) {      
 case "Account":
 if ($subject-&gt;status == "Expired") {
 //send email: "account expired"
 echo "Sending account expired email.\n";
 }
 }
 }
}

$account = new Account();
$account-&gt;status = "Expired";
$account-&gt;save();</pre>
<p>The interfaces aren&#8217;t strictly necessary, but they help make the whole thing clearer (I hope).</p>
<div id="_mcePaste" class="mcePaste" style="position:absolute;left:-10000px;top:843px;width:1px;height:1px;overflow:hidden;">
<pre>$this-&gt;notify($this);</pre>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://cormacscode.wordpress.com/2010/10/12/practical-example-php-implementation-of-the-observer-pattern/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/4ce2ef3cb599c8352679905dac4e919edc01ef92c2ea029a6158f2d7b283ad07?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cormacscode</media:title>
		</media:content>
	</item>
		<item>
		<title>Problems with Japanese characters in MODx</title>
		<link>https://cormacscode.wordpress.com/2010/08/05/problems-with-japanese-characters-in-modx/</link>
					<comments>https://cormacscode.wordpress.com/2010/08/05/problems-with-japanese-characters-in-modx/#comments</comments>
		
		<dc:creator><![CDATA[cormacscode]]></dc:creator>
		<pubDate>Thu, 05 Aug 2010 13:52:13 +0000</pubDate>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[Open source products]]></category>
		<guid isPermaLink="false">http://cormacscode.wordpress.com/?p=149</guid>

					<description><![CDATA[Was having a problem with Japanese characters on a multi-lingual MODx site. I could see that the correct characters were being INSERTed into the database, but when I queried it directly after the insert I got just question marks out. The solution was to change line 10 in manager/includes/config.inc.php from this: $database_connection_method = &#8216;SET CHARACTER [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Was having a problem with Japanese characters on a multi-lingual MODx site. I could see that the correct characters were being INSERTed into the database, but when I queried it directly after the insert I got just question marks out.</p>
<p>The solution was to change line 10 in manager/includes/config.inc.php from this:</p>
<p>$database_connection_method = &#8216;SET CHARACTER SET&#8217;;</p>
<p>to this:</p>
<p>$database_connection_method = &#8216;SET NAMES&#8217;;</p>
<p>The difference between &#8216;SET CHARACTER SET&#8217; and &#8216;SET NAMES&#8217; is &#8216;SET NAMES&#8217; tells mysql server what character set is going to be used in the connection between the server and the client (rather than just what charset will be used on the server and on the client themselves). Because it wasn&#8217;t being used, the mysql server was just guessing the character set, and guessing it wrong.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cormacscode.wordpress.com/2010/08/05/problems-with-japanese-characters-in-modx/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/4ce2ef3cb599c8352679905dac4e919edc01ef92c2ea029a6158f2d7b283ad07?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cormacscode</media:title>
		</media:content>
	</item>
		<item>
		<title>Call a MODx snippet from within a snippet</title>
		<link>https://cormacscode.wordpress.com/2010/04/22/call-a-modx-snippet-from-within-a-snippet/</link>
					<comments>https://cormacscode.wordpress.com/2010/04/22/call-a-modx-snippet-from-within-a-snippet/#comments</comments>
		
		<dc:creator><![CDATA[cormacscode]]></dc:creator>
		<pubDate>Thu, 22 Apr 2010 11:06:56 +0000</pubDate>
				<category><![CDATA[Open source products]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://cormacscode.wordpress.com/?p=144</guid>

					<description><![CDATA[This is really just  a note to remind myself how to to it, I keep forgetting: $modx-&#62;runSnippet(string $snippetName [, array $params]); http://wiki.modxcms.com/index.php/API:runSnippet]]></description>
										<content:encoded><![CDATA[<p>This is really just  a note to remind myself how to to it, I keep forgetting:</p>
<p>$modx-&gt;runSnippet(string $snippetName [, array $params]);</p>
<p><a href="http://wiki.modxcms.com/index.php/API:runSnippet" rel="nofollow">http://wiki.modxcms.com/index.php/API:runSnippet</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://cormacscode.wordpress.com/2010/04/22/call-a-modx-snippet-from-within-a-snippet/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/4ce2ef3cb599c8352679905dac4e919edc01ef92c2ea029a6158f2d7b283ad07?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cormacscode</media:title>
		</media:content>
	</item>
		<item>
		<title>Managing which fields are displayed in a form in the MODx manager</title>
		<link>https://cormacscode.wordpress.com/2010/04/02/managing-which-fields-are-displayed-in-a-form-in-the-modx-manager/</link>
					<comments>https://cormacscode.wordpress.com/2010/04/02/managing-which-fields-are-displayed-in-a-form-in-the-modx-manager/#comments</comments>
		
		<dc:creator><![CDATA[cormacscode]]></dc:creator>
		<pubDate>Fri, 02 Apr 2010 14:19:32 +0000</pubDate>
				<category><![CDATA[Open source products]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://cormacscode.wordpress.com/?p=141</guid>

					<description><![CDATA[There&#8217;s a plugin called managermanager, and the rules are set in /assets/plugins/managermanager/mm_rules.inc.php You can hide fields, tabs and templates from the template dropdown for particular user roles. Handy for uncluttering your admin interface]]></description>
										<content:encoded><![CDATA[<p>There&#8217;s a plugin called managermanager, and the rules are set in /assets/plugins/managermanager/mm_rules.inc.php</p>
<p>You can hide fields, tabs and templates from the template dropdown for particular user roles. Handy for uncluttering your admin interface</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cormacscode.wordpress.com/2010/04/02/managing-which-fields-are-displayed-in-a-form-in-the-modx-manager/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/4ce2ef3cb599c8352679905dac4e919edc01ef92c2ea029a6158f2d7b283ad07?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cormacscode</media:title>
		</media:content>
	</item>
		<item>
		<title>Last resort debugging</title>
		<link>https://cormacscode.wordpress.com/2009/09/04/last-resort-debugging/</link>
					<comments>https://cormacscode.wordpress.com/2009/09/04/last-resort-debugging/#comments</comments>
		
		<dc:creator><![CDATA[cormacscode]]></dc:creator>
		<pubDate>Fri, 04 Sep 2009 16:24:47 +0000</pubDate>
				<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://cormacscode.wordpress.com/?p=138</guid>

					<description><![CDATA[When all else fails, I use The Scientific Method: comment out half the code see if I still get the bug if no then uncomment half the commented-out code and go to step 2 if yes then comment out half the un-commented-out code and go to step 2 It&#8217;s fairly rare I need to do [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>When all else fails, I use The Scientific Method:</p>
<ol>
<li>comment out half the code</li>
<li>see if I still get the bug</li>
<li>if no then uncomment half the commented-out code and go to step 2</li>
<li>if yes then comment out half the <strong>un</strong>-commented-out code and go to step 2</li>
</ol>
<p>It&#8217;s fairly rare I need to do this in php, but currently hacking in vbscript which I don&#8217;t know at all &#8230;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cormacscode.wordpress.com/2009/09/04/last-resort-debugging/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/4ce2ef3cb599c8352679905dac4e919edc01ef92c2ea029a6158f2d7b283ad07?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cormacscode</media:title>
		</media:content>
	</item>
		<item>
		<title>phpunit bootstrap not working in windows</title>
		<link>https://cormacscode.wordpress.com/2009/07/08/phpunit-bootstrap-not-working-in-windows/</link>
					<comments>https://cormacscode.wordpress.com/2009/07/08/phpunit-bootstrap-not-working-in-windows/#comments</comments>
		
		<dc:creator><![CDATA[cormacscode]]></dc:creator>
		<pubDate>Wed, 08 Jul 2009 15:21:01 +0000</pubDate>
				<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://cormacscode.wordpress.com/?p=133</guid>

					<description><![CDATA[While following this tutorial and trying to set up phpunit to work with the Zend Framework, I couldn&#8217;t for the life of me figure out why my phpunit bootstrap seemed to be having no effect whatsoever. When I did figure it out, the problem was an old version of phpunit (3.3.2 instead of 3.3.17) &#8211; [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>While following <a title="Unit testing the zend framework" href="http://www.zendcasts.com/unit-testing-with-the-zend-framework-with-zend_test-and-phpunit/2009/06/" target="_blank">this tutorial</a> and trying to set up phpunit to work with the Zend Framework, I couldn&#8217;t for the life of me figure out why my phpunit bootstrap seemed to be having no effect whatsoever. When I did figure it out, the problem was an old version of phpunit (3.3.2 instead of 3.3.17) &#8211; to update it I had to type (on the windows command line)</p>
<pre>pear upgrade pear</pre>
<p>and then</p>
<pre>pear uninstall phpunit/PHPUnit</pre>
<p>and then</p>
<pre>pear install --alldeps phpunit/PHPUnit</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://cormacscode.wordpress.com/2009/07/08/phpunit-bootstrap-not-working-in-windows/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/4ce2ef3cb599c8352679905dac4e919edc01ef92c2ea029a6158f2d7b283ad07?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cormacscode</media:title>
		</media:content>
	</item>
		<item>
		<title>Enhancing wordpress themes with regular expressions</title>
		<link>https://cormacscode.wordpress.com/2009/06/22/enhancing-wordpress-themes-with-regular-expressions/</link>
					<comments>https://cormacscode.wordpress.com/2009/06/22/enhancing-wordpress-themes-with-regular-expressions/#respond</comments>
		
		<dc:creator><![CDATA[cormacscode]]></dc:creator>
		<pubDate>Mon, 22 Jun 2009 12:51:37 +0000</pubDate>
				<category><![CDATA[Open source products]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://cormacscode.wordpress.com/?p=131</guid>

					<description><![CDATA[I&#8217;ve been using wordpress quite a bit lately, and didn&#8217;t seem to be able to do something I wanted within the confines of a regular wordpress theme. Regular expressions came to the rescue &#8211; you can just use them in your theme and plugin files to do more-or-less anything you want with the content. Here&#8217;s [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://www.wordpress.org" target="_blank">wordpress </a>quite a bit lately, and didn&#8217;t seem to be able to do something I wanted within the confines of a regular wordpress theme. Regular expressions came to the rescue &#8211; you can just use them in your theme and plugin files to do more-or-less anything you want with the content.</p>
<p>Here&#8217;s how I extracted the images so that they weren&#8217;t displayed within the post but instead in another div separate from the post text:</p>
<pre>$images = ""; $matches = array();
if (preg_match_all("/(&lt;img[^&gt;]*&gt;)/iUs",$content,$matches)) {
    $images = implode(" ",$matches[1]);
    $content = preg_replace("/&lt;img[^&gt;]*&gt;/iUs","",$content);
}
$content = "&lt;div class=\"text\"&gt;$content&lt;/div&gt;".
           "&lt;div class=\"images\"&gt;$images&lt;/div&gt;\n";</pre>
<p>See what I did? I grabbed all the image tags out of $content with preg_match_all(), put them all into the variable $images, and then got rid of them all in $content using preg_replace(). Then I displayed $content and $images in separate divs.</p>
<p>You can use it on a page level too &#8211; on the index.php page of a theme, say, you can do an ob_start() to buffer the content, then ob_get_clean() it into a variable and manipulate the variable with regular expressions before echoing it out. So, for example, you could extract all the images or links (or whatever) from the content and display them somewhere else on the page.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cormacscode.wordpress.com/2009/06/22/enhancing-wordpress-themes-with-regular-expressions/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/4ce2ef3cb599c8352679905dac4e919edc01ef92c2ea029a6158f2d7b283ad07?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cormacscode</media:title>
		</media:content>
	</item>
		<item>
		<title>jpg not displaying in nokia browser</title>
		<link>https://cormacscode.wordpress.com/2009/03/30/jpg-not-displaying-in-nokia-browser/</link>
					<comments>https://cormacscode.wordpress.com/2009/03/30/jpg-not-displaying-in-nokia-browser/#respond</comments>
		
		<dc:creator><![CDATA[cormacscode]]></dc:creator>
		<pubDate>Mon, 30 Mar 2009 16:57:42 +0000</pubDate>
				<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://cormacscode.wordpress.com/?p=126</guid>

					<description><![CDATA[Ok so I&#8217;m doing a mobile website. When my application receives a GET request for an image, it uses wurfl to check the User-Agent header and figure out what phone the user has, then resizes the image accordingly (with caching, obviously). It seemed to work fine on every phone in the office except my own [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Ok so I&#8217;m doing a mobile website. When my application receives a GET request for an image, it uses <a href="http://wurfl.sourceforge.net/" target="_blank">wurfl</a> to check the User-Agent header and figure out what phone the user has, then resizes the image accordingly (with caching, obviously).</p>
<p>It seemed to work fine on every phone in the office except my own &#8211; on mine (a basic nokia 2600) the image seemed to download, but just wouldn&#8217;t display (I was left with a correctly-sized blank instead). I could see the image was being generated and cached, and I could even save it on the phone, but when I tried to look at it it wouldn&#8217;t display.</p>
<p>Discovered it worked ok for gifs, and eventually I figured out the problem was jpeg image interlacing. The phone doesn&#8217;t seem to support it &#8211; turned it off and it works fine.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cormacscode.wordpress.com/2009/03/30/jpg-not-displaying-in-nokia-browser/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/4ce2ef3cb599c8352679905dac4e919edc01ef92c2ea029a6158f2d7b283ad07?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cormacscode</media:title>
		</media:content>
	</item>
		<item>
		<title>li bullets displaying in wrong place in IE</title>
		<link>https://cormacscode.wordpress.com/2009/03/13/li-bullets-displaying-in-wrong-place-in-ie/</link>
					<comments>https://cormacscode.wordpress.com/2009/03/13/li-bullets-displaying-in-wrong-place-in-ie/#respond</comments>
		
		<dc:creator><![CDATA[cormacscode]]></dc:creator>
		<pubDate>Fri, 13 Mar 2009 14:14:27 +0000</pubDate>
				<category><![CDATA[css]]></category>
		<guid isPermaLink="false">http://cormacscode.wordpress.com/?p=122</guid>

					<description><![CDATA[If the bullets are showing at the bottom rather than the top of your list items in Internet Explorer and ok in Firefox, then most likely your &#60;li&#62; items have a property called &#8220;layout&#8221;. The hasLayout property gets set by IE depending on the css and can&#8217;t be changed directly &#8211; the few times it&#8217;s [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>If the bullets are showing at the bottom rather than the top of your list items in Internet Explorer and ok in Firefox, then most likely your &lt;li&gt; items have a property called &#8220;layout&#8221;. The hasLayout property gets set by IE depending on the css and can&#8217;t be changed directly &#8211; the few times it&#8217;s happened to me (with css written by someone else), I&#8217;ve fixed it by removing &#8220;li { display: inline-block; }&#8221; from the css.</p>
<p>You can find a detailed explanation of the hasLayout property on <a class="moz-txt-link-freetext" href="http://www.satzansatz.de/cssd/onhavinglayout.html">http://www.satzansatz.de/cssd/onhavinglayout.html</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://cormacscode.wordpress.com/2009/03/13/li-bullets-displaying-in-wrong-place-in-ie/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/4ce2ef3cb599c8352679905dac4e919edc01ef92c2ea029a6158f2d7b283ad07?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cormacscode</media:title>
		</media:content>
	</item>
		<item>
		<title>Triggers within php objects using the __set() magic method</title>
		<link>https://cormacscode.wordpress.com/2009/02/03/triggers-within-php-objects-using-the-__set-magic-method/</link>
					<comments>https://cormacscode.wordpress.com/2009/02/03/triggers-within-php-objects-using-the-__set-magic-method/#comments</comments>
		
		<dc:creator><![CDATA[cormacscode]]></dc:creator>
		<pubDate>Tue, 03 Feb 2009 13:24:19 +0000</pubDate>
				<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://cormacscode.wordpress.com/?p=80</guid>

					<description><![CDATA[I don&#8217;t know if &#8220;trigger&#8221; is the right word for this behaviour, but if you want to automatically cause something to happen when an object variable is updated you can do so like this: &#60;?php class classWithTrigger { private $varOne = 0; private $varTwo = 0; public function __set($varName,$varValue) { $this-&#62;$varName = $varValue; if ($varName [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I don&#8217;t know if &#8220;trigger&#8221; is the right word for this behaviour, but if you want to automatically cause something to happen when an object variable is updated you can do so like this:</p>
<pre>&lt;?php
class classWithTrigger
{
    private $varOne = 0;
    private $varTwo = 0;

    public function __set($varName,$varValue)
    {
        $this-&gt;$varName = $varValue;
        if ($varName == "varOne") {
            $this-&gt;varTwo = $this-&gt;varOne * 9;
        }
    }

    public function __get($varValue)
    {
        return $this-&gt;$varValue;
    }
}

$test = new classWithTrigger;

echo $test-&gt;varOne; // Outputs 0
echo $test-&gt;varTwo; // Outputs 0

$test-&gt;varOne = 1;

echo $test-&gt;varOne; // Outputs 1
echo $test-&gt;varTwo; // Outputs 9</pre>
<p>The __get() method gets called whenever an attempt is made (from outside the class) to get the value of an undefined or inaccessible (private or protected) variable &#8211; in this case it just returns the value as it would if the variable was public. Similarly, the __set() method gets called whenever an attempt is made (from outside the class) to <strong>set</strong> the value of an undefined or inaccessible variable. As you can see, you can use the fact that this gets called to trigger something, whether it&#8217;s an update to another object variable like here, or a DB update, or anything else you can think of.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cormacscode.wordpress.com/2009/02/03/triggers-within-php-objects-using-the-__set-magic-method/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/4ce2ef3cb599c8352679905dac4e919edc01ef92c2ea029a6158f2d7b283ad07?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cormacscode</media:title>
		</media:content>
	</item>
	</channel>
</rss>
