Well I finally got around to getting Zend certified (http://www.zend.com/store/education/certification/authenticate.php?ClientCandidateID=ZEND005928&RegistrationID=222408980). So I thought I'd pass on my impressions of the exam.
Having done around 5 practice exams without much preparation and getting a high grade in each I was expecting to sail through, but the actual exam seemed a bit harder. That's a good thing I guess, no point in it being easy. However the Zend "practice server" claims to be harder than the real thing, so there's a word of warning.
The questions themselves had me scratching my head alot. I thought I knew PHP backwards (palindromic recursive acronym?) but I do not. The questions ranged from syntax and core functions to the newer extensions, design patterns and database design. The exam stretched my knowledge of PHP to the point where I thought I might fail. Enough to make me triple check my answers.
So, without running the code, what is the value of $a?
$a = false + "0xA";
Answers on a postcard...
p.s. question not in exam :p
laserlight
10-10-2007, 02:31 PM
So, without running the code, what is the value of $a?
Goody, I guessed right! It was still a guess though. Are some of the exam questions like that?
If I ever decide to take the ZCE exam, it will only be after I have my compsci degree. No point getting PHP5 certification when PHP6 may well be out and stable when I graduate and start work. On the other hand, PHP5 would probably still be installed on many servers....
Shrike
10-10-2007, 03:45 PM
Some questions are like that, others not. It's a real mixed bag. Most questions are multiple choice though, which makes things alot easier. Some I answered knowing that 3 answers were definitely wrong ;)
halojoy
10-10-2007, 04:17 PM
this would have more interesting, maybe$a = false & "0xA";
NogDog
10-10-2007, 07:27 PM
It's the same as:
NULL + 012; // which does NOT equal twelve
bpat1434
10-10-2007, 09:27 PM
I know I'm gonna sound stupid but.... just how exactly do you learn what it's going to evaluate as? I'm okay with bitwise operators, but the whole hex stuff... totally new to me.... time to learn more....
NogDog
10-10-2007, 10:31 PM
0x indicates that the characters that follow are a hexadecimal number. Since "A" is ten in hexadecimal, [/b]0xA[/b] is the same as 10 in decimal, or 012 in octal ("0" followed by a digit indicates an octal number, then you have 1 in the eights position plus 2 in the ones position). For hex numbers, 0x2B would be 43 in decimal: 2 x 16 plus 11 x 1 (the "B").
bpat1434
10-10-2007, 11:13 PM
Okay, I get that... but where in the world do you learn the hexadecimal equivalents? Do you just reference lookuptable.com or do you just automatically know A is 10, and F is 15 .... ?
EDIT:
Okay, Wikipedia to the rescue.... I think I got it figured.....
NogDog
10-10-2007, 11:26 PM
hexadecimal:
digit position decimal values: 4096 | 256 | 16 | 1
possible digits: 0 1 2 3 4 5 6 7 8 9 A B C D E F
NULL + 012 is probably more confusing, especially if they had an SQL maths question just before or after it.
bpat1434
10-11-2007, 02:41 PM
Okay, what would you use all 4 spots in a hexidecimal spot for? And how could it be done?
NogDog
10-11-2007, 03:10 PM
There is no logical limit to the number of places in a hexadecimal number, just as there is no logical limit to the number of places in a decimal number. Each new place is another power of 16, just as each new place in a decimal number is a power of 10 (or each place in an octal number is a power of 8).
Okay... I get it... kinda..... I still see no real application for it yet though.... Binary I see application for (one of the big ones being access levels).
laserlight
10-11-2007, 04:44 PM
I still see no real application for it yet though.... Binary I see application for (one of the big ones being access levels).
The usefulness of hexadecimal (or octal, for that matter) representation is that it is a condensed form of the binary representation. Consequently, it is as useful as binary, just more succinct.
bpat1434
10-11-2007, 05:09 PM
Oh, okay....
So let me bounce this off you....
Say I have 1024 as my admin level.... I could write that as binary being:
10000000000
(1024 * 1)
Or, represent it in Hex as:
0xFFFF4
((15*16)*4 + (4 * 16))
Is that correct?
mpb001
10-11-2007, 07:04 PM
hex is also used for css/html colours so you probably are using it.
6 little characters hold a lot of colours.
ffffff ( white ) 16777215 decimal
000000 ( black )
Windows calculator scientific mode. Makes life easy.
NogDog
10-11-2007, 08:29 PM
Oh, okay....
So let me bounce this off you....
Say I have 1024 as my admin level.... I could write that as binary being:
10000000000
(1024 * 1)
Or, represent it in Hex as:
0xFFFF4
((15*16)*4 + (4 * 16))
Is that correct?
1024 in decimal would be 400 in hex: ( 4 * 256 ) + ( 0 * 16 ) + ( 0 * 1 ). Thus you see that one advantage of hex is that it generally takes fewer characters to represent a given number. As mentioned in the previous response, you can represent 16,777,216 possible colors with just 6 hex digits (plus the "#" prefix) in web documents.
bpat1434
10-11-2007, 11:06 PM
Oh, okay.... for whatever reason, I keep thinking that Hexadecimal goes 1, 8, 16, 32, 64, instead of 1, 16, 256, 16^3, etc.
Thanks for pointing that out...
troybtj
10-12-2007, 09:17 PM
Oh, okay.... for whatever reason, I keep thinking that Hexadecimal goes 1, 8, 16, 32, 64, instead of 1, 16, 256, 16^3, etc.
Thanks for pointing that out...
<SIDETRACK>
That's close to octal, which is used to describe the bits on file permissions in a unix system with 'chmod'.
When you chmod 777, you are putting all '1's in user, group, and world in the file permission byte, each triplet of bits is "Read, Write, Execute", first the special file bit, then owner triplet, group triplet, and world triplet:
s o g w
- rwx rwx rwx = 777
0 421 421 421 = binary -> decimal
0 111 111 111 = binary
most common is 755
rwx r-x r-x - Only owner can write, world can read/execute
The highest order bit states is a "special" flag for directories, symbolic links, sockets, etc.
</SIDETRACK>
Weedpacket
10-13-2007, 05:45 AM
When you're done there you can move on to mixed-radix notations. In fixed-radix the value of each digit place is a fixed multiple of the place to its right (ten for decimal, sixteen for hexadecimal, eight for octal, two for binary...). In mixed-radix the steps are uneven in size.
I kid: you're already familiar with them. Think years, months, days, hours, minutes, seconds. Or miles, yards, feet, inches. Or hundred-dollar notes, fifty-dollar notes, twenty-dollar notes, ten-dollar notes...
If you don't mind not being able to represent zero (except with an empty string), another fixed-radix positional system has digits [1..n] instead of [0..n-1] which is usual for base n. Dyadic has two digits, 1 and 2. The numerals continue: 1, 2, 11, 12, 21, 22, 111, 112, 121, 122, 211, 212, ... The radix is the same as for binary: 122 = 1*4+2*2+2 = ten.
Then there are the other bases for a positional system: -2, 1-i, Fibonacci (a mixed-radix system where the radices are integer approximation to powers of (sqrt(5)+1)/2)...
Samgilljoy
10-16-2007, 07:44 PM
Okay, I get that... but where in the world do you learn the hexadecimal equivalents? Do you just reference lookuptable.com or do you just automatically know A is 10, and F is 15 .... ?
EDIT:
Okay, Wikipedia to the rescue.... I think I got it figured.....
Well, were you a really old guy like me, you would have probably played the Traveller RPG in 80's, where all the character stats were in Hexadecimals. So, really awesome character stats looked like CDEEFFA.
I recall a few days of grade-school algebra, when Hexadecimals were covered, but I don't think they ever told us why.
Now, the sexigesimal system, that was useful for all the Babylonian Astronomers in the back row.
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.