About the Author

author photo

Adam Trachtenberg is the Director of the LinkedIn Developer Network, where he oversees developer relations and marketing for the LinkedIn Platform. Before LinkedIn, Adam worked at eBay in platform product management and marketing. Even earlier, he co-founded Student.Com and TVGrid.com. Adam is the author of PHP Cookbook and Upgrading to PHP 5. He lives in San Francisco.

See All Posts by This Author

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.

There Are 2 Responses So Far. »

  1. stolen from c# I suspect.

  2. I think it’s from Unix, wise guy. Don’t you have a baby to help deliver?

Post a Response