Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Mark Story's Blog:
New errors in PHP 5.4
Dec 30, 2011 @ 08:30:45

In this quick new post to his blog Mark Story talks about two new errors he ran across when upgrading his installation to PHP 5.4, both showing up under E_ALL.

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.

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 the various Changelogs for each Release Candidate and beta release.

tagged: new error update version warning notice offset string

Link:

Slawek Lukasiewicz's Blog:
PHP application diagnostics - Memtrack
Nov 08, 2011 @ 12:08:37

Slawek Lukasiewicz has posted about a handy tool that can be used to track memory consumption and performance in your PHP application - memtrack.

Application profiling can help us determine bottlenecks and possible problems during development. But sometimes we also need to diagnose problems in production environment. Frequent performance problems are connected with functions and methods using too much memory.

The tool allows you to set up thresholds for memory consumption and, if the scripts exceeds it, add warnings to your log files. He includes the simple instructions to install it (via PECL) and enable it in your php.ini. Some sample code to create a memory overvload is included to test it out. Configuration options let you set the limits and define functions to ignore if you know for sure there's trouble spots.

tagged: memtrack extension diagnostic limit warning

Link:

PHP.net:
5.3.7 upgrade warning
Aug 22, 2011 @ 12:32:48

In a quick note from the PHP.net site, they have a warning for those running PHP 5.3.7 (the most recent release) - there's a bug that's serious enough (with crypt) to where upgrades should probably wait until 5.3.8.

Due to unfortunate issues with 5.3.7 (see bug#55439) users should wait with upgrading until 5.3.8 will be released (expected in few days).

The issue causes the crypt() function to only return the (MD5-only) salt it was given instead of the correctly hashed string. If you need to replace this immediately, you can pull the latest from the snaps site (or binaries for Windows). Keep an eye out for PHP 5.3.8 in the near future.

tagged: version crypt salt md5 hash warning upgrade

Link:

Lorna Mitchell's Blog:
Declaring Static Methods in PHP
Dec 10, 2010 @ 08:40:45

Lorna Mitchell has a new post to her blog today talking about static methods and how to use them correctly in your code (as discovered accidentally in her own code).

I was confused recently to realise that I had accidentally called a static method in PHP dynamically from another part of my code; I expected PHP to output warnings when this is done. On closer inspection I discovered that: static functions can be called dynamically and dynamic functions generate an E_STRICT error if called statically.

She illustrates with some sample code that, when run with E_ALL and E_STRICT throws a warning from the strict side about calling a non-static method statically. She also talks about why it throws this warning for the non-static call on a static method. She also explains why, when a static method is called dynamically, no warning is thrown.

tagged: declaring static method warning strict

Link:

Misko Hevery's Blog:
Guide: Writing Testable Code
Jan 07, 2009 @ 10:29:39

In this slightly older (Nov 2008) but useful post to Misko's blog, he takes a look at a few common flaws that you should avoid in writing up your code (in any language really).

To keep our code at Google in the best possible shape we provided our software engineers with these constant reminders. Now, we are happy to share them with the world.

Here's the list of the flaws:

  • Flaw #1: Constructor does Real Work
  • Flaw #2: Digging into Collaborators
  • Flaw #3: Brittle Global State & Singletons
  • Flaw #4: Class Does Too Much

Each includes some warning signs to keep an eye out for to see if you and your code might be straying the wrong way.

tagged: testable guide hint flaw avoid warning sign

Link:

PHPFreaks.com:
Debugging: A Beginner's guide
Jun 10, 2008 @ 07:59:13

On PHPFreaks.com there's a new tutorial providing a beginner's guide to debugging in PHP (with the built in functionality PHP has, not external software).

Everyday the forums see probably hundreds of topics posted where the problem is a fairly simple error. [...] As a beginner, it can be difficult to find and solve these errors. By tackling each of these in turn, I hope to teach you some methods of finding and solving them.

They look at the different sorts of errors - syntax errors, fatal errors, warnings, notices - as well as some of the ones a bit harder to track down like database problems and logical errors.

tagged: debug beginner guide parse warning fatal error notice

Link:

Mindoop Blog:
SEO Warning : Zend framework and duplicate content
Nov 21, 2007 @ 07:54:00

On the Mindoop blog, there's a new post talking about some of the issues that the Zend Framework could cause with the SEO for your site - a simple reason, really.

Zend framework is becoming a first choice framework for a large percentage of PHP developers. It's native support for advanced URL routing makes implementing search engine optimized URLs a breeze. Or not?

Because of the reserved words for the controllers and the multiple ways to access the actions below it (his example is case_studies, case-studies and case)studies) make three different ways to get to the same content - a SEO no-no.

tagged: seo warning zendframework duplicate content seo warning zendframework duplicate content

Link:

Mindoop Blog:
SEO Warning : Zend framework and duplicate content
Nov 21, 2007 @ 07:54:00

On the Mindoop blog, there's a new post talking about some of the issues that the Zend Framework could cause with the SEO for your site - a simple reason, really.

Zend framework is becoming a first choice framework for a large percentage of PHP developers. It's native support for advanced URL routing makes implementing search engine optimized URLs a breeze. Or not?

Because of the reserved words for the controllers and the multiple ways to access the actions below it (his example is case_studies, case-studies and case)studies) make three different ways to get to the same content - a SEO no-no.

tagged: seo warning zendframework duplicate content seo warning zendframework duplicate content

Link:

The Bakery:
Clear the PHP4 warnings when working in eclipsePHP
Feb 20, 2007 @ 12:47:00

CakePHP users can find a quick hint from The Bakery today pointing out how to get ride of some of the warning messages when working with the framework in PHP4.

CakePHP - a great framework, but sometimes surprising to those who are used to programming with PHP 5. EclipsePHP spits out pages and pages of warnings when compiling towards a PHP 5 base, scaring new CakePHP converts.

The method involves performing a global search and replace on seven key strings to help them conform to the CakePHP standards. The warnings will "magically" disappear following.

tagged: eclipsephp warning php4 cakephp framework search replace eclipsephp warning php4 cakephp framework search replace

Link:

The Bakery:
Clear the PHP4 warnings when working in eclipsePHP
Feb 20, 2007 @ 12:47:00

CakePHP users can find a quick hint from The Bakery today pointing out how to get ride of some of the warning messages when working with the framework in PHP4.

CakePHP - a great framework, but sometimes surprising to those who are used to programming with PHP 5. EclipsePHP spits out pages and pages of warnings when compiling towards a PHP 5 base, scaring new CakePHP converts.

The method involves performing a global search and replace on seven key strings to help them conform to the CakePHP standards. The warnings will "magically" disappear following.

tagged: eclipsephp warning php4 cakephp framework search replace eclipsephp warning php4 cakephp framework search replace

Link: