<?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>Sun, 12 Feb 2012 21:05:49 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[DevShed: Effects of Wrapping Code in Class Constructs]]></title>
      <guid>http://www.phpdeveloper.org/news/17320</guid>
      <link>http://www.phpdeveloper.org/news/17320</link>
      <description><![CDATA[<p>
DevShed has a new tutorial posted today looking to help you counteract the bad practice of <a href="http://www.devshed.com/c/a/PHP/PHP-Effects-of-Wrapping-Code-in-Class-Constructs/">wrapping procedural code in "class" constructs</a> and provide some useful suggestions of how to avoid it.
</p>
<blockquote>
Static helpers seem to be a great idea at first glance, as they're reusable components that don't require any kind of expensive instantiation for doing common tasks [...]. But the sad and unavoidable truth is in many cases they're simply wrappers for procedural code, which has been elegantly hidden behind a "class" construct. So what's wrong with this? Well, even in the most harmless situations, when you use a static helper that produces a deterministic output, you're actually throwing away the advantages that OOP provides.
</blockquote>
<p>
To illustrate, they create a basic validation class that can check for things like valid emails, float values, integers and URLs using PHP's <a href="http://php.net/filter_var">filter_var</a> function. They point out that the class is difficult to extend and that it is doing too many things to be correctly considered a "piece" of functionality. To correct the problem, they opt for a different approach - an abstract class acting as an interface to structure custom validators against. This provides set/get methods for things like the error message and value to evaluate. The implementation of the validators on top of this class is coming in the next part of the series.
</p>]]></description>
      <pubDate>Thu, 29 Dec 2011 10:06:58 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Brandon Savage's Blog: Custom Apps: Some Strategies For Easy Configuration Files]]></title>
      <guid>http://www.phpdeveloper.org/news/13229</guid>
      <link>http://www.phpdeveloper.org/news/13229</link>
      <description><![CDATA[<p>
In <a href="http://www.brandonsavage.net/custom-apps-some-strategies-for-easy-configuration-files/">this new post</a> to his blog today <i>Brandon Savage</i> looks at configuration options for PHP apps and gives some examples to help you get the thought process started for your development.
</p>
<blockquote>
One of the decisions that has to be made each time an application is written for distribution is how best to set up the configuration files. There are a number of different approaches taken to this: some opt to use the define() function and define constants, while others use large arrays. 
</blockquote>
<p>
He points out a few "overlooked options" that some developers might no consider when working with configuration files like class constants and ini files (which PHP can <a href="http://us.php.net/manual/en/function.parse-ini-file.php">parse natively</a>). A few code snippets are included to show examples of them in use.
</p>]]></description>
      <pubDate>Wed, 16 Sep 2009 07:59:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Paul Reinheimer's Blog: Memcached Constants - Lame Code]]></title>
      <guid>http://www.phpdeveloper.org/news/12716</guid>
      <link>http://www.phpdeveloper.org/news/12716</link>
      <description><![CDATA[<p>
If you've worked with memcached and have ever run into an error, you might get tossed a code, the value of the error's constant, rather than the actual constant name. <i>Paul Reinheimer</i> was seeing just that and decided to map out all of the constants in relation to their error codes for future reference.
</p>
<blockquote>
I was running into a few errors, and <a href="http://ca3.php.net/manual/en/memcached.getresultcode.php">getResultCode()</a> was obligingly returning the value of the constant, rather than the <a href="http://ca3.php.net/manual/en/memcached.constants.php">constant</a> itself. I had to look up what that value meant. For some reason I couldn't reflect the extension to get the constants and values thereof, so with some lame scraping you get the following.
</blockquote>
<p>
He's included the list in both a normal text format and as a PHP array that can be cut and pasted directly into a library.
</p>]]></description>
      <pubDate>Fri, 19 Jun 2009 10:27:26 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Joseph Crawford's Blog: MySpace PHP REST Library]]></title>
      <guid>http://www.phpdeveloper.org/news/12433</guid>
      <link>http://www.phpdeveloper.org/news/12433</link>
      <description><![CDATA[<p>
For those still looking to interface with <a href="http://myspace.com">MySpace</a>, <i>Joseph Crawford</i> has <a href="http://josephcrawford.com/2009/04/28/myspace-php-rest-library/">pointed out</a> an <a href="http://wiki.developer.myspace.com/index.php?title=Category:MDP_Libraries#Official_MySpace_REST_API_PHP_Library">official REST library</a> for PHP to connect with their API.
</p>
<blockquote>
Over the last few days I have been digging deep into the concepts of REST. I have been reading through my copy of <a href="http://www.amazon.com/RESTful-Web-Services-Leonard-Richardson/dp/0596529260/ref=sr_1_1?ie=UTF8&s=books&qid=1240926906&sr=8-1">RESTful Web Services</a>. Out of curiosity I searched <A href="http://josephcrawford.com/2008/09/30/google-releases-update-engine/">Google</a> for a "php REST library" and it turned up the <a href="http://wiki.developer.myspace.com/index.php?title=Category:MDP_Libraries#Official_MySpace_REST_API_PHP_Library">Official MySpace PHP REST Library</a>.
</blockquote>
<p>
He points out one interesting thing about it, though - it's like they started using an object-oriented design but build after making the classes with properties. No methods.
</p>
<blockquote>
Even if they were to choose to go the PHP 5 way I would highly suggest that they do not use classes as containers for constants, there is no need to do this. It is not using proper OOP methodologies. Why create an object that just holds 2 - 4 constant variables, these would be better suited for define() calls in my opinion.
</blockquote>]]></description>
      <pubDate>Thu, 30 Apr 2009 10:25:55 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Packt Publishing: PHP Magic Features]]></title>
      <guid>http://www.phpdeveloper.org/news/12335</guid>
      <link>http://www.phpdeveloper.org/news/12335</link>
      <description><![CDATA[<p>
Packt Publishing has <a href="http://www.packtpub.com/article/php-magic-features">posted a new article</a> from <i>Jani Hartikainen</i> about the "magic methods" that PHP comes with - methods, properties and constants really.
</p>
<blockquote>
Magic methods, which are class methods with specific names, are used to perform various specialized tasks. They are grouped into two: overloading methods and non-overloading methods. [...] Magic functions, which are similar to magic methods, but are just plain functions outside any class. [...] Magic constants, which are similar to constants in notation, but act more like "dynamic" constants. We'll also look at some practical examples of using some of these, and lastly we'll check out what new features PHP 5.3 is going to add.
</blockquote>
<p>
He looks at the various functions/methods and constants (like __clone, __toString), some of the overloading methods like __call, and magic constants like __FILE__ and __CLASS__. He wraps it up by briefly discussing what PHP 5.3 adds in - a few new magic methods and constants (but no functions).
</p>
]]></description>
      <pubDate>Tue, 14 Apr 2009 09:31:48 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP in Action Blog: I want enums in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/10159</guid>
      <link>http://www.phpdeveloper.org/news/10159</link>
      <description><![CDATA[<blockquote>I want Enums in PHP</blockquote>
<p>
That's how <a href="http://www.reiersol.com/blog/index.php?op=ViewArticle&articleId=36&blogId=1">this new post</a> on the PHP in Action blog starts this morning. The one thing that he wants is enumeration support in PHP. He shows how it can currently come close with a "roles" system:
</p>
<blockquote>
Useful examples I've encountered in web programming are states or stages in a process and user roles. Another kind of example is one I used in PHP In Action: an authorization system with three fixed roles or categories of user: regular, webmaster and administrator.
</blockquote>
<p>
He sets up an example class that sets constants for the different access levels rather than just relying on strings to handle it (which, as he points out, could very easily be misspelled and not throw any kind of error) .
</p>]]></description>
      <pubDate>Mon, 12 May 2008 08:41:16 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Hasin Hayder's Blog: Web scrapping in a smart way, making a "Today in History" object in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/10063</guid>
      <link>http://www.phpdeveloper.org/news/10063</link>
      <description><![CDATA[<p>
<i>Hasin Hayder</i> has written up a <a href="http://hasin.wordpress.com/2008/04/29/web-scrapping-in-a-smart-way-making-a-today-in-history-object/">quick tutorial</a> for his blog that shows how to create your own "Today in History" page with details from <a href="http://www.scopesys.com/">Scopesys</a> pulled with a little web scraping.
</p>
<blockquote>
There are thousands of services available on web who are presenting interesting as well as education information which you can really integrate in your web page or make a nice widget and let others use them seamlessly with their content delivery platforms. In this article I am going to show you how you can make a nice Today-in-History widget with the help of the data provided in <a href="http://www.scopesys.com/">Scopesys</a>.
</blockquote>
<p>
He wisely recommends that you check one thing first about the content you're grabbing - the copyright it carries with it. This could get you into big trouble down the line depending on whose content it is. The actual script is pretty simple - he defines some constants as markers for where things start and stop in the HTML and then uses strpos to get the locations for his substr call to grab the segments.
</p>]]></description>
      <pubDate>Tue, 29 Apr 2008 10:27:41 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Michael Kimsal's Blog: Another PHP bugbear…]]></title>
      <guid>http://www.phpdeveloper.org/news/9741</guid>
      <link>http://www.phpdeveloper.org/news/9741</link>
      <description><![CDATA[<p>
<i>Micheal Kimsal</i> has <a href="http://michaelkimsal.com/blog/?p=478">pointed out</a> another "bugbear" he's found in his work with PHP - this time it's with the use of class constants.
</p>
<blockquote>
My issue is not with the language itself (this time!) but how this sort of documentation is handled. Updating public documentation well ahead of a release creates confusion.
</blockquote>
<p>
He's referring to the documentation for the class constants not quite matching up with the current functionality (resulting in a T_PAAMAYIM_NEKUDOTAYIM). He wants consistency in the documentation and maybe references to what it requires to use a certain bit of code. 
</p>]]></description>
      <pubDate>Wed, 05 Mar 2008 19:08:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Lars Strojny's Blog: New magic constant in PHP 5.3]]></title>
      <guid>http://www.phpdeveloper.org/news/9691</guid>
      <link>http://www.phpdeveloper.org/news/9691</link>
      <description><![CDATA[<p>
In <a href="http://usrportage.de/archives/878-New-magic-constant-in-PHP-5.3.html">this new blog post</a> today, <i>Lars Strojny</i> talks about a new magic constant that will be joining its brothers in the upcoming PHP 5.3 release - __DIR__.
</p>
<blockquote>
In PHP 5.3 there will be another magic constant __DIR__. [...] To allow this, the internal function php_dirname() has been moved in the Zend Engine and is now called zend_dirname(). Nevertheless an alias still exists.
</blockquote>
<p>
__DIR__ will join the other constants (like __LINE__ and __FUNCTION__) to help give the currently running script a little introspection for things like its filename, what class it's currently in and now, what directory the file currently lives in.
</p>]]></description>
      <pubDate>Fri, 22 Feb 2008 15:02:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Stefan Koopmanschap's Blog: Tip: use clearly readable variable names, and constants!]]></title>
      <guid>http://www.phpdeveloper.org/news/9180</guid>
      <link>http://www.phpdeveloper.org/news/9180</link>
      <description><![CDATA[<p>
<i>Stefan Koopmanschap</i> has <a href="http://www.leftontheweb.com/message/Tip_use_clearly_readable_variable_names_and_constants">a good reminder</a> for developers out there in a new post to his blog - make your code much easier to understand via readable variable names and constants.
</p>
<blockquote>
Yes, you know what code you write and you also know how it works. You can find your way around it. But what if you haven't touched a piece of code for months or even years. Or what if someone else needs to work with your code. Prevent a hell: use clearly readable variable names and constants.
</blockquote>
<p>
He points out an example of what not to do - a specific line from the FUDForum code with multiple variables named with a single letter of the alphabet in a complex if() evaluation. He suggests even using "namespacing" of sorts (PHP6 here we come!) to help compartmentalize your variables to make things even easier.
</p>]]></description>
      <pubDate>Wed, 05 Dec 2007 12:05:00 -0600</pubDate>
    </item>
  </channel>
</rss>

