<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sat, 22 Nov 2008 00:20:54 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[David Otton's Blog: Neat PHP Tricks: How To Assign References to Globals]]></title>
      <guid>http://www.phpdeveloper.org/news/11375</guid>
      <link>http://www.phpdeveloper.org/news/11375</link>
      <description><![CDATA[<p>
<i>David Otton</i> has a new <a href="http://www.otton.org/2008/11/09/neat-php-tricks-assign-references-globals-workaround/">neat PHP trick</a> posted today - assigning references to global values.
</p>
<blockquote>
What follows isn't so much a PHP trick as a fix for something that really should work, but doesn't. Although the manual implies that the behaviour described below is specific to Zend Engine 1, all my tests were performed against Zend Engine 2.2, PHP 5.2.5.
</blockquote>
<p>
His example compares making a new stdClass both with and without a reference on the it and <a href="http://www.php.net/var_dump">var_dumps</a> out the result. The method with the reference fails silently, however and isn't able to correctly assign it to the global. He recommends a work-around though - setting it directly to the $GLOBALS superglobal.
</p>]]></description>
      <pubDate>Mon, 10 Nov 2008 09:32:18 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Sebastian Bergmann's Blog: Global Variables and PHPUnit]]></title>
      <guid>http://www.phpdeveloper.org/news/10424</guid>
      <link>http://www.phpdeveloper.org/news/10424</link>
      <description><![CDATA[<p>
<i>Sebastian Bergmann</i> has a <a href="http://sebastian-bergmann.de/archives/797-Global-Variables-and-PHPUnit.html">new post</a> today about a feature of the PHPUnit unit testing tool that has the possibility of breaking when objects are introduced - backing up the globals.
</p>
<blockquote>
It is hard to test code that uses singletons. The same is true for code that uses global variables. Typically, the code you want to test is coupled strongly with a global variable and you cannot control its creation. An additional problem is the fact that one test's change to a global variable might break another test.
</blockquote>
<p>
You can disable the backup option if you'd like by setting the $backupGlobals option in your test to false. This lets PHPUnit know that you want to leave the globals (and superglobals) alone during the run.
</p>]]></description>
      <pubDate>Tue, 17 Jun 2008 08:49:19 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Derick Rethans' Blog: Namespaces in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/10415</guid>
      <link>http://www.phpdeveloper.org/news/10415</link>
      <description><![CDATA[<p>
After hearing <i>Stefan Priebsch</i>'s talk at this year's Dutch PHP Conference, something occurred to <i>Derick Rethans</i> - there was a small sort of issue with using namespaces and possible future PHP's own namespace.
</p> 
<blockquote>
One of the things that came up is the conflicts that can arise with internal classes. In PHP 5.3 this would alias the class Interval in the namespace PEAR::Date to the class Interval. For now, this code would work just fine. However, if PHP would introduce a class "Interval" at some point in the future (and PHP can do this as it <a href="http://www.php.net/manual/en/userlandnaming.rules.php">owns the global namespace</a>) then the above code would suddenly stop working
</blockquote>
<p>
He offers <a href="http://derickrethans.nl/namespaces_in_php.php">a simple solution</a> that can prevent this sort of conflict for the future - defining your "use" and then creating a new instance of the namespace into a variable instead of just an "as".
</p>]]></description>
      <pubDate>Mon, 16 Jun 2008 07:54:39 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Stoyan Stefanov's Blog: PHP-style $GLOBALS in Javascript?]]></title>
      <guid>http://www.phpdeveloper.org/news/9780</guid>
      <link>http://www.phpdeveloper.org/news/9780</link>
      <description><![CDATA[<p>
In a <a href="http://www.phpied.com/php-style-globals-in-javascript/">new post</a> to his blog today, <i>Stoyan Stefanov</i> has a proposal to being something PHP users are very used to - superglobals - over to Javascript.
</p>
<blockquote>
Javascript has implied globals. When you skip the var in var a = 1; and go a = 1;, then a becomes a global variable. Some consider this an error in the language. [...] In PHP on the other hand, variables are local. [...] So how about this: adopt the $GLOBALS convention in your JavaScripts?
</blockquote>
<p>
His <a href="http://www.phpied.com/php-style-globals-in-javascript/">example</a> proposes the creation of a GLOBALS object you can assign properties to that can be used anywhere. This helps to keep the variables you truely want to be global contained, though it doesn't do much except provide a convention.
</p>]]></description>
      <pubDate>Wed, 12 Mar 2008 07:55:07 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[SitePoint PHP Blog: What's so bad about the Singleton?]]></title>
      <guid>http://www.phpdeveloper.org/news/9624</guid>
      <link>http://www.phpdeveloper.org/news/9624</link>
      <description><![CDATA[<p>
On the SitePoint PHP Blog today <i>Troels Knak-Nielsen</i> asks th3e question "what's so bad about the singleton?" For all of its advantages, is there a darker side of the design pattern when it pertains to global variables.
</p>
<blockquote>
As I have often taken this stance myself, I found it reasonable that I should be able to argue for it, so I'll try to give an explanation. This is also in part a follow-up on <a href="http://www.sitepoint.com/blogs/2008/02/04/dealing-with-dependencies/">my post from last week</a>, in which I present a way to avoid global symbols, without spending much time on why.
</blockquote>
<p>
He <a href="http://www.sitepoint.com/blogs/2008/02/13/whats-so-bad-about-the-singleton/">talks about</a> what they are and how they're commonly used - sometimes with some unpleasant side effects because of their use of globals.
</p>]]></description>
      <pubDate>Wed, 13 Feb 2008 12:13:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Mike Naberezny's Blog: __get() - an alternative to __autoload()]]></title>
      <guid>http://www.phpdeveloper.org/news/4627</guid>
      <link>http://www.phpdeveloper.org/news/4627</link>
      <description><![CDATA[<i>Mike Naberezny</i> has <a href="http://www.mikenaberezny.com/archives/38">posted this new item</a> on his blog today with a look at why __get() is a perfectly good alternative to __autoload() in a class structure.
<p>
<quote>
<i>
<a href="http://www.php.net/__autoload">__autoload()</a> is a magic function introduced in PHP 5 that provides a mechanism for on-demand loading of classes. After its inclusion in PHP, many argued that using such a feature is too magical or not a good design practice. Putting the religious debates over the appropriateness of __autoload() aside, its implementation does have one significant drawback: it is a function declared in the global scope. Once a function is declared, it cannot be redeclared. This means __autoload() can't be used effectively in shared libraries, since any other code could have already declared it.
<p>
Similar lazy-load functionality can be achieved on the class level by using <a href="http://www.php.net/manual/en/language.oop5.overloading.php">__get()</a>.
</i>
</quote>
<p>
He <a href="http://www.mikenaberezny.com/archives/38">gives a short code example</a> where the __get() call mimics the functionality of __autoload(), but the resulting object created is public, not global...]]></description>
      <pubDate>Wed, 09 Jan 2008 06:47:54 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Arnold Daniels' Blog: Perl like temporary variables in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/8961</guid>
      <link>http://www.phpdeveloper.org/news/8961</link>
      <description><![CDATA[<p>
<i>Arnold Daniels</i> <a href="http://blog.adaniels.nl/?p=58">points out</a> a quick method for creating what he calls "perl-like temporary variables" in the global scope of a script:
</p>
<blockquote>
When writing code in the global scope, I often have a problem where I'm overwriting a variable. This happens even more often when I work on code of somebody else. Usually has the variable which does the overwriting is usually just a temporary variable.
</blockquote>
<p>
<a href="http://blog.adaniels.nl/?p=58">His code</a> is a simple few lines that shows how it could be used when trying to write information out to a file handle. Some of the comments on the post criticize his use of the global scope but <i>Arnold</i> comes back with his reasoning - mostly that there is already code in the global scope and that adding something else is only adding to it, not making things worse.
</p>]]></description>
      <pubDate>Fri, 02 Nov 2007 09:38:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[SitePoint PHP Blog: Dynamic global functions in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/8879</guid>
      <link>http://www.phpdeveloper.org/news/8879</link>
      <description><![CDATA[<p>
On the SitePoint PHP blog, there's a <a href="http://www.sitepoint.com/blogs/2007/10/21/dynamic-global-functions-in-php/">quick tutorial</a> from <i>Troels Knak-Nielsen</i> about the creation and use of dynamic global functions in your PHP application:
</p>
<blockquote>
Like many others, I prefer to use procedural PHP as a template language. While PHP's syntax makes it a practical choice for this, there is a problem with embedding dynamic content. [...] A single letter, regular function is undoubtedly the simplest way to extend PHP's syntax. Thinking about it, it's fairly obvious, but it just never occurred to me. [...] There is a problem though; Since this is such a good name for a function, chances are that someone else would use it for something different, or perhaps even for the same.
</blockquote>
<p>
As a more viable solution, he recommends <a href="http://www.sitepoint.com/blogs/2007/10/21/dynamic-global-functions-in-php/">going dynamic</a> and creating fumctions (via the call_user_func_* functions) and an addition to the $GLOBALS superglobal to make calling the custom function simpler.
</p>]]></description>
      <pubDate>Mon, 22 Oct 2007 11:12:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Soledad Penades' Blog: Signs your PHP needs refactoring]]></title>
      <guid>http://www.phpdeveloper.org/news/7980</guid>
      <link>http://www.phpdeveloper.org/news/7980</link>
      <description><![CDATA[<p>
As <a href="http://feeds.feedburner.com/~r/funkablog/~3/122396798/">mentioned by</a> <i>Ed Finkler</i>, there's a list of <a href="http://www.soledadpenades.com/2007/06/05/signs-your-php-needs-refactoring/">signs your PHP needs refactoring</a> from <i>Soledad Penades</i>.
</p>
<blockquote>
<p>
I have had to go through a php application recently which has given me more than one headache and has required me to use all my possible patience. While working with it, I thought This is good material for an article, so that nobody else does the same in the future, and nobody else will need to experience the same displeasure as I have had to.
</p>
<p>
So here are the signs your PHP application needs a serious refactoring, right now
</p>
</blockquote>
<p>
Included in <a href="http://www.soledadpenades.com/2007/06/05/signs-your-php-needs-refactoring/">the list</a> are things like:
</p>
<ul>
<li>Uses global variables
<li>Everything's an array
<li>The neverending switch
<li>Interface inconsistency
</ul>
<p>
It hits on one of the thing that bugs me too, the problem of "Brackets galore" - so many subarrays that you have to resort to three or more sets of bracketed keys to get to the value you want. It's bad enough trying to follow someone else's code without having to "trace down" an array to figure out which of the values they're talking about.
</p>]]></description>
      <pubDate>Tue, 05 Jun 2007 16:26:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Community News: Userland Naming Guide Launched]]></title>
      <guid>http://www.phpdeveloper.org/news/6029</guid>
      <link>http://www.phpdeveloper.org/news/6029</link>
      <description><![CDATA[<p>
An <a href="http://www.php.net/manual/en/userlandnaming.php">official guide</a> to choosing names for identifiers in userland has been added to the PHP manual on PHP.net. In <a href="http://pooteeweet.org/blog/466">his latest post</a>, <i>Lukas Smith</i> talks about it:
</p>
<blockquote>
<p>
So now we finally have some guidelines on how users should name their identifiers to be fairly future proof. This should hopefully help reduce the amount of pain people suffer when PHP adds new features like a class for Date or File handling. Although the two mentioned examples have settled on using DateTime and FileObject to get around the issue at least partially.
</p>
<p>
The <a href="http://www.php.net/manual/en/userlandnaming.php">guide itself</a> is unfortunately spread over 3 pages, which does not seem to make sense since there is really not that much content there yet. Then again the guide may get expanded in the future. Anyways I recommend that every serious PHP programmer have a look at the guide. If there are any issues please let me (or the PHPDoc team) know. Otherwise make sure you adapt your internal CS to match this guide.
</p>
</blockquote>
<p>
The guide talks about the naming of items in the global namespace (functions, classes, interfaces, etC), some rules to follow for internal identifiers, and some quick tips on naming to create pseudo-namespaces.
</p>]]></description>
      <pubDate>Mon, 14 Aug 2006 11:37:26 -0500</pubDate>
    </item>
  </channel>
</rss>
