<?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:30:39 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Nikita Popov's Blog: htmlspecialchars() improvements in PHP 5.4]]></title>
      <guid>http://www.phpdeveloper.org/news/17462</guid>
      <link>http://www.phpdeveloper.org/news/17462</link>
      <description><![CDATA[<p>
In <a href="http://nikic.github.com/2012/01/28/htmlspecialchars-improvements-in-PHP-5-4">this new post</a> to his blog <i>Nikita Popov</i> looks at an update that might have gotten lost in the shuffle of new features coming in PHP 5.4 - some updates to <a href="http://php.net/htmlspecialchars">htmlspecialchars</a>.
</p>
<blockquote>
One set of changes that I think is particularly important was largely overlooked: For PHP 5.4 cataphract (Artefacto on StackOverflow) heroically rewrote large parts of htmlspecialchars thus fixing various quirks and adding some really nice new features. Here a quick summary of the most important changes: UTF-8 as the default charset, improved error handling (ENT_SUBSTITUTE) and Doctype handling (ENT_HTML401,...).
</blockquote>
<p>
He goes into each of these three main features in a bit more detail, providing code to illustrate the improved error handling and the new flags for Doctype handling (covering HTML 4.01, HTML 5, XML 1 and XHTML).
</p>]]></description>
      <pubDate>Mon, 30 Jan 2012 09:55:24 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Moon's Blog: Errors when adding/subtracing dates using seconds]]></title>
      <guid>http://www.phpdeveloper.org/news/17406</guid>
      <link>http://www.phpdeveloper.org/news/17406</link>
      <description><![CDATA[<p>
<i>Brian Moon</i> has <a href="http://brian.moonspot.net/errors-adding-subtracting-dates">a reminder about date handling</a> in PHP - days are not always 86400 seconds long, sometimes there's "leap seconds" included too. Thankfully, there's easy ways around it:
</p>
<blockquote>
The problem with this is that it assume that there are only 86400 seconds in every day. There are in fact not. On days when the clocks change for daylight savings time, there are either 1 hour more than that or 1 hour less than that. In addition, there are also <a href="http://en.wikipedia.org/wiki/Leap_second">leap seconds</a> put into our time system to keep us in line with the sun. There is one this year, 2012, on June 30th in fact. Since they don't happen with the regularity that daylight savings time does, it may be easy to forget those. Luckily, for this problem, the solution is the same.
</blockquote>
<p>
His first solution involves letting <a href="http://php.net/strtotime">strtotime</a> do the work for him, internally calculating the leap seconds or any other issue that might come up. As an alternate solution, he also mentions "doing your math at noon" - this gives you enough leeway to make the offset leap seconds could cause a much smaller risk.
</p>]]></description>
      <pubDate>Tue, 17 Jan 2012 11:19:22 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Mark Story's Blog: New errors in PHP 5.4]]></title>
      <guid>http://www.phpdeveloper.org/news/17324</guid>
      <link>http://www.phpdeveloper.org/news/17324</link>
      <description><![CDATA[<p>
In <a href="http://mark-story.com/posts/view/new-errors-in-php-5-4">this quick new post</a> to his blog <i>Mark Story</i> talks about two new errors he ran across when upgrading his installation to PHP 5.4, both showing up under E_ALL.
</p>
<blockquote>
I've been running the PHP5.4 RC builds for the last few months, and there are some interesting changes in the upcoming PHP release. On top of all the great new features coming in PHP5.4. After updating to PHP5.4-RC4, a few things that used to not trigger errors and silently do the wrong thing, now trigger notices or warnings.
</blockquote>
<p>
The two he mentions deal with a new warning on illegal string offsets and the other about string offsets ("Notice: String offset cast occurred"). You can find out about more changes in the PHP 5.4 series in <a href="http://php.net/releases/">the various Changelogs</a> for each Release Candidate and beta release.
</p>]]></description>
      <pubDate>Fri, 30 Dec 2011 08:30:45 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: Handling SQL Errors in PDO]]></title>
      <guid>http://www.phpdeveloper.org/news/17134</guid>
      <link>http://www.phpdeveloper.org/news/17134</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> has a quick new post showing one way to <a href="http://www.lornajane.net/posts/2011/handling-sql-errors-in-pdo">handle SQL errors in PDO</a> that could pop up because of badly written/generated SQL statements.
</p>
<blockquote>
I love <a href="http://php.net/pdo">PHP's PDO (PHP Data Objects)</a> extension; it gives a consistent, object-oriented interface to handling all kinds of relational database backends. One thing that annoys me is that the MySQL driver for PDO defaults to a silent error mode which can make SQL errors tricky to spot!
</blockquote>
<p>
In her two code snippets she shows a failing PDO request (that fails silently) and a method for catching this issue - checking the result of the "<a href="http://us2.php.net/manual/en/pdo.errorcode.php">errorCode</a>" method to see if it equals "0" (zero). If there were errors, you can use the "<a href="http://us2.php.net/manual/en/pdo.errorinfo.php">errorInfo</a>" function to get to them. This will return the SQL error code, the driver-specific error code and a driver-specific error message.
</p>]]></description>
      <pubDate>Wed, 16 Nov 2011 09:43:34 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Error Handling in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17110</guid>
      <link>http://www.phpdeveloper.org/news/17110</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial from <i>Sneha Heda</i> looking at <a href="http://phpmaster.com/error-handling-in-php/">error handling in PHP</a> - the types of errors that can come up, how to throw your own and how to catch them appropriately.
</p>
<blockquote>
Errors are the most common event a developer faces when programming. [...] To help reduce the number of errors in your code, and to mitigate their effects, proper error handling is essential in your web application. This article is a crash course in PHP error handling. You'll learn about PHP's built-in error reporting levels, and how to handle errors with custom error handlers and exception handling.
</blockquote>
<p>
She starts with the different error reporting levels PHP offers, everything from the lightweight E_NOTICE out to E_ALL|E_STRICT. With this as a reference, she shows how to create a custom error handler (using <a href="http://php.net/set_error_handler">set_error_handler</a>). Also included is a look at exceptions and some of the more detailed information that comes with them - line numbers, messages, file the error was thrown from, etc.
</p>]]></description>
      <pubDate>Thu, 10 Nov 2011 08:41:39 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Ian Barber's Blog: Linear Regression in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16991</guid>
      <link>http://www.phpdeveloper.org/news/16991</link>
      <description><![CDATA[<p>
<i>Ian Barber</i> has a new post about an interesting method for determining the "line" that results follow in your statistics - <a href="http://phpir.com/linear-regression-in-php">linear regression in PHP</a> (complete with code samples).
</p>
<blockquote>
There are a lot of problems that fall under predicting these types of continuous values based on limited inputs - for example: given the air pressure, how much rain will there be, given the qualifying times, how quick will the fastest lap be in the race. By taking a bunch of existing data and fitting a line, we will be able to make a prediction easily - and often reasonably correctly.
</blockquote>
<p>
He defines two pieces of information, the intercept and the gradient, and how they relate to minimize the "square error" that can come from getting the square root of your values based on the difference between an actual and predicted value. Based on a sample data set, he comes up with <a href="http://phpir.com/user/files/postim1/Screen%20shot%202011-10-12%20at%2011.12.06.png">these results</a>, showing the trend line for the points given. He points out a few issues with the method and corrects them with a few tweaks to his original algorithm.
</p>]]></description>
      <pubDate>Thu, 13 Oct 2011 12:57:09 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Display errors on screen even with display errors = off with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16977</guid>
      <link>http://www.phpdeveloper.org/news/16977</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has posted a handy tip to his blog today about <a href="http://gonzalo123.wordpress.com/2011/10/10/display-errors-on-screen-even-with-display-errors-off-in-php/">showing errors even with "display_errors" being off</a> in your application (could be helpful in debugging those difficult problems).
</p>
<blockquote>
 Shared hosting are cheap, but normally they don't allow us the use some kind of features. For example we cannot see the error log. That's a problem when we need to see what happens within our application. Normally I work with my own servers, and I have got full access to error logs. But if we cannot see the error log and the server is configured with <a href="http://es.php.net/manual/en/errorfunc.configuration.php#ini.display-errors">display errors = off</a> in php.ini (typical configuration in shared hosting), we have a problem.
</blockquote>
<p>
His solution involves an "error sniffer" script that captures the issues in a script and echoes them out at the end. In <a href="https://github.com/gonzalo123/ErrorSniffer">his ErrorSniffer</a> he sets up a custom error, exception and shutdown handler to grab the problems and capture them for later use - including echoing them out to the user if desired.
</p>]]></description>
      <pubDate>Tue, 11 Oct 2011 11:03:07 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Moon's Blog: Check for a TTY or interactive terminal in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16809</guid>
      <link>http://www.phpdeveloper.org/news/16809</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Brian Moon</i> describes a need he had for detecting if the client or user calling a PHP script was <a href="http://brian.moonspot.net/tty-or-interactive-terminal-in-php">using an interactive terminal (TTY)</a> or not:
</p>
<blockquote>
Let's say I am trying to find out why some file import did not happen. Running the job that is supposed to do it may yield an error. Maybe it was a file permission issue or something. There are other people watching the alerts. What they don't know is that I am running the code and looking at these errors in real time.
</blockquote>
<p>
Since the errors were being sent to the log file, they were lost to the client/user on the other end left staring at their script wondering what went wrong. He ended up with a solution (a pretty simple one too) that uses <a href="http://www.php.net/posix_ttyname">posix_ttyname</a> and <a href="http://php.net/posix_isatty">posix_isatty</a>. He includes the little snippet of code he puts in his prepend file that checks for errors then checks for a TTY. If both are there, it turns off logging the errors to the file and sends them direct instead.
</p>]]></description>
      <pubDate>Fri, 02 Sep 2011 09:12:47 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ldeveloper Tech Blog: PHP - Fatal error: Uncaught SoapFault exception: Could not connect to host...]]></title>
      <guid>http://www.phpdeveloper.org/news/16712</guid>
      <link>http://www.phpdeveloper.org/news/16712</link>
      <description><![CDATA[<p>
On the Ldeveloper Tech Blog today there's a helpful new post about an error PHP's SOAP extension could throw <a href="http://ldeveloper.blogspot.com/2011/08/php-fatal-error-uncaught-soapfault.html">about not being able to connect to the host</a> despite all settings being correct.
</p>
<blockquote>
I receive this nasty error yesterday and it took me some time to figure out the problem: "Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in...". This ["new SoapClient"] line passes without any problems and this [var_dump on __getFunctions] shows the function prototypes correctly.
</blockquote>
<p>
His script connects to the service as its supposed to but the "could not connect" is still thrown. He found a few references to OpenSSL issues that could cause it, but his code was correct so he turned to the other side - the service itself. As it turns out, it wasn't configured correctly.
</p>
<blockquote>
It was configured to send invalid url and the function calls were using that invalid url. So there are two solutions [...]  the first is to configure the server correctly. The other is to give __doReguest the correct location.
</blockquote>]]></description>
      <pubDate>Fri, 12 Aug 2011 11:38:04 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[David Stockton's Blog: Changing ErrorController to work with AJAX]]></title>
      <guid>http://www.phpdeveloper.org/news/16709</guid>
      <link>http://www.phpdeveloper.org/news/16709</link>
      <description><![CDATA[<p>
<i>David Stockton</i> has a new tutorial posted to his blog - a technique he's found useful in his Zend Framework application to make the <a href="http://zendtutorials.com/tutorial/changing-errorcontroller-to-work-with-ajax/">ErrorController work with Ajax calls</a> to reduce the message you get back to just a JSON response.
</p>
<blockquote>
If you've ever built a Zend Framework MVC app which makes AJAX calls, you may have noticed that if an error occurs, you'll get a chunk of JSON followed by the HTML for the error page. If you've built a layout, you'll get all of that back to. This is fine if your users hit the page in the browser but it can cause problems with your JavaScript being able to correctly decode your JSON.
</blockquote>
<p>
The fix is pretty simple, though, and only requires that you add the error handling action to the Ajax context to force it to drop the layout and any other HTML that might come along with the view. He includes a bit more code to have the error handler include the exceptions and pass them out to be included in the JSON response.
</p>]]></description>
      <pubDate>Fri, 12 Aug 2011 08:58:06 -0500</pubDate>
    </item>
  </channel>
</rss>

