PHP Posts

DB::DBAL DB::DBAL is a lightweight Database Abstraction Layer that is designed to allow for multiple database types and connections simultaneously. DB::DBAL provides ease of use of use through query chaining,...

Read more

Form Builder To be perfectly honest, this is a class I built awhile ago (back in November of 2010), so going from memory here. But basically, Form Builder allows you to setup a databased/ emailed form quickly and...

Read more

Weekly PHP Test What is the output of the following code? [php]echo (string) 042;[/php] ... ... ... ... ... ... ... ... ... ANSWER: [crayon]34[/crayon] Because the number starts...

Read more

Weekly PHP Test What does the following code echo out: [php] if('ORANGE' > 'apple') { echo 'orange'; } else { echo 'apple'; } [/php] ... ... ... ... ... ... ANSWER: [crayon]apple[/crayon] The...

Read more

PHP 5.4 – First Glances Updated February 10, 2012 PHP 5.4 is just around the corner, and with it several new features and enhancements.  Here are just a few of the features I've had the chance to play with that may be useful. Binary...

Read more

  • Prev
  • Next

Weekly PHP Test

Category : Weekly Test

What is the output of the following code?

PHP
1
echo (string) 042;

ANSWER:

1
34

Because the number starts with a zero, it is interpreted as an Octal number instead of a decimal. This means instead of returning 42 as one might expect, it returns the octal calculation:

0 = signify Octal
4 = 4 x 8 = 32
2 = 2 X 1 = 2
—————-
34

Facebook Twitter Linkedin Digg Reddit Stumbleupon Tumblr Posterous Email Snailmail
Share

Weekly PHP Test

Category : Weekly Test

What does the following code echo out:

PHP
1
2
3
4
5
if('ORANGE' > 'apple') {
echo 'orange';
} else {
echo 'apple';
}

→ Continue

Facebook Twitter Linkedin Digg Reddit Stumbleupon Tumblr Posterous Email Snailmail
Share

Weekly PHP Test

Category : Weekly Test

True or False: In PHP 5.4 Traits can have properties?

→ Continue

Facebook Twitter Linkedin Digg Reddit Stumbleupon Tumblr Posterous Email Snailmail
Share

Weekly PHP Test

Category : Weekly Test

What does the following code produce in PHP 5.0+

PHP
1
2
3
4
5
6
$var = (object) array('0'=>'hello world');
if(isset($var[0])) {
die('Is Set');
}
die('Not Set');

→ Continue

Facebook Twitter Linkedin Digg Reddit Stumbleupon Tumblr Posterous Email Snailmail
Share

Weekly PHP Test

Category : Weekly Test

In PHP empty(array()) returns true, where-as empty(array(1)) returns false. What does the following code produce in PHP 5.0+

PHP
1
2
3
4
5
6
$var = (object) array();
if(empty($var)) {
die('Is Empty');
} else {
die('Is Not Empty');
}

→ Continue

Facebook Twitter Linkedin Digg Reddit Stumbleupon Tumblr Posterous Email Snailmail
Share

Weekly PHP Test

Category : Weekly Test

Assuming $cache->load($key) contains a cache of “yes” and $mediaCacheEnabled = true, what will the var_dump of $data return in this case?

PHP
1
2
3
4
5
if (!$data = $cache->load($key) || !$mediaCacheEnabled) {
$data = 'no';
}
var_dump($data);

→ Continue

Facebook Twitter Linkedin Digg Reddit Stumbleupon Tumblr Posterous Email Snailmail
Share