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 does the following code echo out:

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

ANSWER:

1
apple

The values are converted based on the ASCII alphabet, in which uppercase letters come before lowercase letters, and thus are assigned a lower value than the lowercase letters. This means that the word ‘apple’ is assigned a higher value than the word ‘ORANGE’ because of the case-sensitivity, making ‘apple’ greater than ‘ORANGE.’ When we change ‘ORANGE’ to lowercase, the otherwise same code would return ‘orange.’

Facebook Twitter Linkedin Digg Reddit Stumbleupon Tumblr Posterous Email Snailmail
Share

Post a comment