<?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>Thu, 23 May 2013 17:03:33 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Chris Hartjes: Testing Smells - Try/catch]]></title>
      <guid>http://www.phpdeveloper.org/news/19531</guid>
      <link>http://www.phpdeveloper.org/news/19531</link>
      <description><![CDATA[<p>
In <a href="http://www.littlehart.net/atthekeyboard/2013/04/30/testing-smells-try-catch/">this new post</a> to his site <i>Chris Hartjes</i> gives an example of what he calls a "testing smell". This particular illustration deals with the poor handling of testing and exceptions with try/catch blocks.
</p>
<blockquote>
As part of a project to migrate the PHP code at work from PHP 5.2 to PHP 5.4, I'm using our extensive test suite to look for instances where something that changed between the versions of PHP that we are using has caused some unexpected behaviour. In one of our code bases, I found some tests that are exhibiting a test smell through their use of a try / catch block in the test itself.
</blockquote>
<p>
He includes a (contrived) example showing the use of an exception in a unit test to run an assertion in the "catch" for the test to pass. He points out that this particular check is being done to see if the user input is valid...and that it's a bad way to enforce it using exceptions. He also suggests that if you have an "if" situation, don't use one test with logic in it, write two tests. He mentions a <a href="http://www.brianfenton.us/2011/09/bad-practice-setting-expected.html">disenting opinion</a> but notes that a failing test is a failing test, regardless of what caused the failure.
</p>
Link: http://www.littlehart.net/atthekeyboard/2013/04/30/testing-smells-try-catch]]></description>
      <pubDate>Wed, 01 May 2013 11:42:29 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sankuru Blog: Adding support for if/while/do while, to a simple compiler & virtual machine in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17346</guid>
      <link>http://www.phpdeveloper.org/news/17346</link>
      <description><![CDATA[<p>
Improving on his <a href="http://phpdeveloper.org/news/17327">last post</a> about creating a bytecode compiler in PHP, the Sankuru blog has a new post in the series looking at extending the basic compiler to <a href="http://sankuru.biz/blog/13-adding-support-for-if-while-and-do-while-to-a-simple-compiler-and-virtual-machine-written-in-php">add support for if/while and do while</a> logic.
</p>
<blockquote>
In order to obtain a <a href="http://en.wikipedia.org/wiki/Turing_completeness">turing-complete</a> programming language, that is, a language in which we can implement and execute any arbitrary algorithm, that is, that other turing-complete machines can execute too, we now need to add a way of (conditionally) branching, that is, the IF statement, and at least one way of repeating statements, that is the WHILE or the DO WHILE statements.
</blockquote>
<p>
He includes a simple TL-based script as an end goal for the compiler to be able to execute and shows how to add rules for it to the lexer/parser. Rules for the "if" are relatively simple, but there's a hitch in dealing with embedded "while" statements he had to work around. The post ends with the bytecode results for the sample program and the resulting output from the compiled versions execution.
</p>]]></description>
      <pubDate>Wed, 04 Jan 2012 11:40:22 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Using the Ternary Operator]]></title>
      <guid>http://www.phpdeveloper.org/news/17068</guid>
      <link>http://www.phpdeveloper.org/news/17068</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial showing the use of a sometimes overlooked (but very handy) alternate syntax that PHP includes - the <a href="http://phpmaster.com/using-the-ternary-operator/">ternary operator</a>, a short-hand if/else.
</p>
<blockquote>
You're probably already familiar with PHP's if statement. It's very similar to its counterparts in many other programming languages and represents one of the most fundamental concepts in programming. [...] But there's a way to build on this concept and increase your $coolFactor a bit in the process. Allow me to introduce you to the ternary operator, which serves as a shorthand notation for if statements.
</blockquote>
<p>
They introduce the ternary operator's syntax, the ":" and "?" operators and includes a few pieces of code showing its use. Thankfully they also include a warning - don't overuse or abuse it...and especially don't nest them - that just leads to headaches.
</p>]]></description>
      <pubDate>Tue, 01 Nov 2011 09:43:35 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPBuilder.com: Loops & Decisions in PHP - The ABC's of PHP Part 8]]></title>
      <guid>http://www.phpdeveloper.org/news/12475</guid>
      <link>http://www.phpdeveloper.org/news/12475</link>
      <description><![CDATA[<p>
PHPBuilder.com has posted <a href="http://www.phpbuilder.com/columns/peter_shaw05062009.php3">the eighth part</a> of their introductory "ABCs of PHP" series today. This time the focus is on looping and decision functionality (like if/while/for/etc).
</p> 
<blockquote>
n any given computer language (PHP is no exception) there has to be a way to allow the running code to decide between doing 2 different things. If there wasn't then software would not be able to adapt based on operating conditions, or it wouldn't be able to decide between two different users. 
</blockquote>
<p>
They look at using: if statements and operators, for loops and while loops. When they look at the operators, they talk about the differences between equals/not equals, grater than/less than and two of the boolean operators - AND and OR.
</p>]]></description>
      <pubDate>Thu, 07 May 2009 10:26:34 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ask About PHP: PHP's alternative syntax and why it's useful]]></title>
      <guid>http://www.phpdeveloper.org/news/12353</guid>
      <link>http://www.phpdeveloper.org/news/12353</link>
      <description><![CDATA[<p>
On the "Ask About PHP" blog today there's <a href="http://www.askaboutphp.com/beginners/59/phps-alternative-syntax-and-why-its-useful.html">a new post</a> looking at some of the alternative syntaxes that PHP has to offer for control structures.
</p>
<blockquote>
PHP offers an alternative way to write their control structures for as long as I've remembered. It basically does away with the curly brackets and replaces the opening curly with a colon (:) and the closing with '˜end'-whatever. I have to be honest and say I've never really found a need to use the alternative syntax, simply because I'm so used to using the curly braces after so many years of using PHP. Plus, it's less typing!
</blockquote>
<p>
The one specifically mentioned deals with "if" evaluations. There's two other options to the usual braces method - one being a shorthand using colons and a semicolon and the other using the <a href="http://php.net/ternary">ternary syntax</a>.
</p>]]></description>
      <pubDate>Thu, 16 Apr 2009 07:50:56 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Rob Thompson's Blog: Switch vs. If]]></title>
      <guid>http://www.phpdeveloper.org/news/9549</guid>
      <link>http://www.phpdeveloper.org/news/9549</link>
      <description><![CDATA[<p>
<i>Rob Thompson</i> has <a href="http://rob.sun3.org/php-code/switch-vs-if/">posted about</a> some simple benchmarking he did comparing the speed of a series of "if" statements versus one "switch" with multiple cases.
</p>
<blockquote>
I got curious about which is actually more efficient at matching a random integer with a set of conditionals. So, I setup a script to create a set of large scripts to test the speed of these different constructs. Using the 'time' command, I measured the speed at which the condition could match a random number.
</blockquote>
<p>
His results found that the switch statement is generally more than 2 times as fast at matching a simple integer. His tests, however, didn't go through much more than this simple test. It'd be interesting to see what it would do with something more complex (like longer strings or handling the result of an evaluation inside the definition of the switch().
</p>]]></description>
      <pubDate>Fri, 01 Feb 2008 14:28:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Kore Nordmann's Blog: Evil bugs in your code]]></title>
      <guid>http://www.phpdeveloper.org/news/9171</guid>
      <link>http://www.phpdeveloper.org/news/9171</link>
      <description><![CDATA[<p>
<i>Kore Nordmann</i> has <a href="http://kore-nordmann.de/blog/evil_code_bugs.html">made a quick post</a> to his blog about some "evil bugs" he's seen reoccurring in the code he writes and wanted to point them out so other developers might learn from them.
</p>
<blockquote>
Those are 4 typical errors I introduced in my code, and spend some time debugging it, because I found them really hard to spot. Luckily, once I spotted the actual bug, I find it a lot easier the next time the typo occurs. Therefore I want to share those, so that I may save you some minutes of your life hunting stupid bugs.
</blockquote>
<p>
His three contributions concern a "missing if", the addition of a random semicolon, operator precedence and a for loop that refuses to work. Others have contributed to the comments on the post as well.
</p>]]></description>
      <pubDate>Tue, 04 Dec 2007 11:52:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: PHP Statements and Beginning Loops]]></title>
      <guid>http://www.phpdeveloper.org/news/8969</guid>
      <link>http://www.phpdeveloper.org/news/8969</link>
      <description><![CDATA[<p>
DevShed has posted the <a href="http://www.devshed.com/c/a/PHP/PHP-Statements-and-Beginning-Loops/">latest part</a> of their introduction to PHP series, this time focusing on one of the more useful features of the language - conditionals and loops.
</p>
<blockquote>
We discussed statements briefly in our last article and even got a sneak peek of an IF-statement. Sure I mean, the image was blurry, and the moment it saw us it ran off into the forest. But we saw it. Honest. So in this article, we're going to take a much closer look at PHP statements and even start learning about loops.
</blockquote>
<p>
They cover if statements (as mentioned) as well as introduce you to its companions, else and else if. The finish off the article with a brief look at one of the simpler loops, the <a href="http://www.devshed.com/c/a/PHP/PHP-Statements-and-Beginning-Loops/4/">for loop</a>.
</p>]]></description>
      <pubDate>Mon, 05 Nov 2007 09:34:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Debugging and Performance]]></title>
      <guid>http://www.phpdeveloper.org/news/6761</guid>
      <link>http://www.phpdeveloper.org/news/6761</link>
      <description><![CDATA[<p>
In another part of their series of excerpts from the Zend PHP Certification Guide (from Zend), DevShed has posted <a href="http://www.devshed.com/c/a/PHP/Debugging-and-Performance/">this article</a> talking about debugging and performance issues and methods.
</p>
<blockquote>
Making mistakes is human, and so is fixing them. In your day-to-day programming adventures, it's inevitable to introduce bugs in your PHP code, especially when you're writing very complex applications with tens of thousands of lines of code spread across tens of files.
</blockquote>
<p>
In <a href="http://www.devshed.com/c/a/PHP/Debugging-and-Performance/">this article</a> they look at things like flattening if statements, spplitting single commands across multiple lines, and the difference between =, ==, and ===.
</p>]]></description>
      <pubDate>Thu, 23 Nov 2006 13:42:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Matthew Batchelder's Blog: Writing Your Server-Side Ajax Handler]]></title>
      <guid>http://www.phpdeveloper.org/news/5038</guid>
      <link>http://www.phpdeveloper.org/news/5038</link>
      <description><![CDATA[<i>Matthew Batchelder</i> describes in <a href="http://borkweb.com/story/a-simple-server-side-ajax-handler">his latest post</a> about the other half of an equation he demonstrated in <a href="http://borkweb.com/story/ajax-templating-and-the-separation-of-layout-and-logic">this previous post</a> - the creation of an Ajax handler.
<p>
<quote>
<i>
In my recent post on '<a href="http://borkweb.com/story/ajax-templating-and-the-separation-of-layout-and-logic">Ajax; Templating; and the Separation of Layout and Logic</a>,' I refer to an Ajax Handler that sits server side to handle Ajax calls. Some elaboration is in order.
<p>
As I have <a href="http://borkweb.com/story/prototype-makes-javascript-painless">stated in the past</a>, I'm a huge fan of <a href="http://prototype.conio.net/">Prototype</a> AND I choose <a href="http://php.net/">PHP</a> as my language of choice...so my examples will be using both, but the idea is portable.
</i>
</quote>
<p>
His <a href="http://borkweb.com/story/a-simple-server-side-ajax-handler">example</a> is a very basic one, pulling in the data from the $_GET values and, with a combination of dynamic function calls and the use of eval(), provides a simple "framework" to handle your Ajax calls. There are two versions of the same thing - one using if statements and the other a switch and various cases.]]></description>
      <pubDate>Thu, 23 Mar 2006 12:37:17 -0600</pubDate>
    </item>
  </channel>
</rss>
