Thoughts, rants and commentary from a husband, father of five and professional web geek

Fun with PHP

Posted on July 24th, 2008 in PHP, Web Development | 2 Comments »

Every now and again someone writes a line or two of code that really makes me smile. Such is the case with this outcome determinating and decision making class below. This code is being reproduced, with or without consent, from the PHP Developers Network’s own scottayy.

<?php
/**
 * Coin flipper class helps determine outcome of situations in which an outcome
 * cannot be decided by sheer manpower alone.
 * 
 * @author Scott Martin <scottayy@devnetwork.net>
 * @license None, don't even try to use this or your hair will turn yellow
 */
class coin {
	/**
	 * The outcome determinators
	 * 
	 * Each invocation of this object will require a determinator upon which the
	 * object relies to build a determined outcome. These are those determinators.
	 * 
	 * @access private
	 * @var array
	 */
	private static $_sides = array('heads', 'tails');
 
	/**
	 * The determinating method
	 * 
	 * This method, when called, invokes a determination sequence and returns a
	 * determined value for use in decision making.
	 * 
	 * @access public
	 * @return string Randomly selected determinator
	 */
	public static function flip() {
		// Quick, randomize me some determinators
		shuffle(self::$_sides);
 
		// Quick, offer it back before it gets angry
		return self::$_sides[mt_rand(0, 1)];
	}
}
 
/**
 * We should always test our determinating decision establisher
 *
 * 2,4,6,8 You know you want to determinate
 */
echo coin::flip();
?>

For those that just have to have an object to instantiate (and you know who you are), there is this lightly modified version for your obsessive/compulsive selves:

<?php
/**
 * Coin flipper class helps determine outcome of situations in which an outcome
 * cannot be decided by shear manpower alone.
 * 
 * @author Scott Martin <scottayy@devnetwork.net>
 * @license None, don't even try to use this or your hair will turn yellow
 */
class coin {
	/**
	 * The outcome determinators
	 * 
	 * Each invocation of this object will require a determinator upon which the
	 * object relies to build a determined outcome. These are those determinators.
	 * 
	 * @access private
	 * @var array
	 */
	private $_sides = array('heads', 'tails');
 
	/**
	 * The determinating method
	 * 
	 * This method, when called, invokes a determination sequence and returns a
	 * determined value for use in decision making.
	 * 
	 * @access public
	 * @return string Randomly selected determinator
	 */
	public function flip() {
		// Quick, randomize me some determinators
		shuffle($this->_sides);
 
		// Quick, offer it back before it gets angry
		return $this->_sides[mt_rand(0, 1)];
	}
}
 
/**
 * We should always test our determinating decision establisher
 */
$coin = new coin;
 
/**
 * 2,4,6,8 You know you want to determinate
 */
echo $coin->flip();
?>

See, just looking at that code makes you want to smile doesn’t it? Geeks are great.

Back to top

How would improve the look of this site?

Posted on June 21st, 2008 in Personal Messages | 2 Comments »

I have made a good many changes to this theme in the few days that it has been alive. Since its launch a few day ago I have asked for critiques and constructive criticism from the PHP Developers Network. However, I think it might be better to ask your opinion as well seeing you might not visit the PHPDN community (tsk, tsk).

So I ask you, dear reader, if you were going to improve upon the way this theme appears, what would you do? What changes would you make if you were the designer?

I appreciate any responses you provide. I am looking forward to making this theme a usable, intuitive, clean interface and could use any and all feedback presented.

Thanks.

Back to top

A bit of irony in the PHP world

Posted on May 19th, 2008 in Geek Stuff, PHP, Web Development | No Comments »

According to an article today by TechCrunch, Zend Technologies, The PHP company, is cutting 25% of their PHP developer staff, perhaps with an eye towards selling the company.

Israeli startup Zend Technologies has fired 25 percent of its R&D team (at least ten people), as well as others across the company, in an attempt to become cash flow positive, says a source close to the company. A spokesperson from the company’s PR firm says: “Yes, I can confirm that Zend made the layoffs, but we cannot comment on the numbers or reasons for the action.”

Read the complete TechCrunch article here.

As I read the brief article I began to think that this is not really anything that should be too newsworthy. Many companies in the USA, and around the world in general, are feeling the pinch of a down economy. Companies have to do what they can to reduce cost while maintaining competitive prices for goods and services. What Zend is doing is not really that out of the ordinary.

And I am not sure that Zend, as a company, is really worth a huge amount of money like the Sun Microsystems acquisition of MySQL was. It might be tasty to some of the players in the industry right now like Oracle, IBM or even a Sun. But really, other than the Zend engine and the Zend IDE what exactly does Zend have to offer?

Whatever happens to Zend from all of this one thing is very important to remember. Many a PHP developer now has the opportunity to seek gainful employment from other companies that are seeking, heavily, PHP talent. Many Silicon Valley companies, including many companies in the social networking space, are looking for top tier PHP talent right now. Companies like Ning, Digg, Facebook, Technorati, Yahoo and Google are constantly hiring PHP developers.

Times are good for being a PHP developer. Maybe not so much if you worked for Zend. Nonetheless, now is a great time to know a great deal about PHP.

Back to top