PHP Trivia Contest: DOM + Default Namespaces

Here’s a question based on a recent PHP bug report which shows why DOM is fun.

Given the following line of PHP:

$xml = DOMDocument::loadXML(
'<r xmlns="urn:a"/>');

The easy way to print the namespace URI of the root node, urn:a, is:

echo $xml->documentElement->namespaceURI;

But how do you retrieve it using DOMElement::GetAttributeNS()? What are the two magical input parameters to coax that value out?

Popularity: 34% [?]

PHP 5 + COM + Skype Help Wanted

This is a help wanted ad. Any assistance would be much appreciated.

I’m trying to use PHP 5.2 to talk to Skype via the COM extension and Skype4COM interface.

I’m using this example from the Skype Forum, but I get a COM exception of “Skype client is not installed.”

However, I do have Skype on my machine and I’m not the only one with this problem, so I don’t think I’m completely crazy.

Unfortunately, I don’t normally develop on Windows or Skype, so it’s very hard for me to debug the COM extension. If anyone has some pointers on where I should start, it would be very useful. Thanks!

Popularity: 26% [?]

Stupid PHP one liners: Google calc

A long time ago, I wrote a two line hack that let you use Google as a command line calculator. It eventually ended up in the 2nd and 3rd editions of Google Hacks.

I don’t know what caused by to look at that code again, but here’s the one line version:

print str_replace('<font size=-2> </font>', ',' ,
  preg_replace('(.+<b>.+= (.+?)</b>.+)s', '$1',
    file_get_contents('' .
      urlencode(join(' ', array_splice($argv, 1)))))) . "\n";

Popularity: 8% [?]

View maps in Google search results

I came across a new (to me) feature of Google today: inline maps.

Popularity: 6% [?]

eBay Developer Program: Needs Biz Dev Techie

The group at eBay where I work, the Developers Program, is looking to hire a biz dev person that’s also at least a little techie.

Here’s the key requirements:

  • Work with eBay’s Internet Marketing and Product Management teams to define and enable third-party development of applications to drive activity to
  • Evangelize and communicate the benefits of developing on the eBay Platform using our Application Programming Interface (API) and other web services to third parties (primarily affiliates) through conference appearances, one-on-one interaction and personal innovation.
  • Maintain and continue to develop/streamline the platform access infrastructure for third parties.

And here’s the full description. (If that link doesn’t work, go to and search for job “12439BR”.)

If you’re interested, please e-mail me. The domain is “” and my username is “atrachtenberg”.

Popularity: 5% [?]

My favorite new style of printf

I just discovered vsprintf(), which accepts a formatting string and an array of arguments:

// logging function that accepts printf-style formatting
// it prints a time stamp, the string, and a new line
function logf() {
	$date = date(DATE_RSS);
	$args = func_get_args();
	$format = array_shift($args);

	return print "$date: " . vsprintf($format, $args) . "\n";

Just sharing.

Popularity: 4% [?]

Did you know about PHP’s old_function?

I was reviewing Upgrading to PHP 5 today and I came across this lovely section in Appendix B, which I had completely forgotten about:

PHP/FI had a quirky function declaration syntax:

function sum $a, $b (
    return($a + $b);

This was changed in PHP 3, but you could continue to use the old form in PHP 3 and PHP 4 if you declared your function as an old_function:

old_function sum $a, $b (
    return($a + $b);

Alas, after six years, this backward compatibility feature is now gone. Another nostalgic remnant of PHP/FI has passed away.

I must say, I used PHP/FI, but I never resorted to the old_function hack to ease my PHP 3 migration issues.

Did anybody ever use this?

Popularity: 4% [?]

Auctioning Autographed “Upgrading to PHP 5″ for the EFF

Every since I started at eBay, I’ve been looking to sell more on the site. I’ve also been looking to donate more money to charity. So I decided to combine the two: I’m selling a copy of Upgrading to PHP 5 on eBay and donating everything to the EFF.

The EFF, short for Electronic Frontier Foundation, describes themselves as:

[A] group of passionate people — lawyers, technologists, volunteers, and visionaries — working in the trenches, battling to protect your rights and the rights of web surfers everywhere. The dedicated people of EFF challenge legislation that threatens to put a price on what is invaluable; to control what must remain boundless.

List priced at $29.99, the auction starts at $0.01, so you’re guaranteed to get a good value. As an extra special bonus, I will custom autograph the book to the winning bidder or a friend. Or, for an additional $5, I will not sully up your clean new book with my autograph. Your choice. Okay, just kidding about the $5.

If you’ve been looking to get up to speed on PHP 5, now’s the perfect chance to buy a book and give money to a great cause. Check out my listing and bid today.

Popularity: 8% [?]