Well I finally got around to getting Zend certified. 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

    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....

      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 😉

        this would have more interesting, maybe

        $a = false & "0xA";

          It's the same as:

          NULL + 012;  // which does NOT equal twelve
          

            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....

              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").

                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.....

                  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
                  
                  octal:
                  digit position decimal values:   512 |  64 |   8  |  1
                  possible digits:  0 1 2 3 4 5 6 7
                  

                    NULL + 012 is probably more confusing, especially if they had an SQL maths question just before or after it.

                      Okay, what would you use all 4 spots in a hexidecimal spot for? And how could it be done?

                        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).

                        decimal   hexadecimal  octal      binary
                        --------  -----------  ---------  ------------------------
                               1         1             1                         1
                               2         2             2                        10
                               8         8            10                      1000
                              10         A            12                      1010
                              16        10            20                     10000
                            1000       3E8          1750                1111101000
                        16777215    FFFFFF      77777777  111111111111111111111111
                        

                          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).

                            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.

                              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
                              ((1516)4 + (4 * 16))

                              Is that correct?

                                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.

                                  bpat1434 wrote:

                                  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
                                  ((1516)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.

                                    Oh, okay.... for whatever reason, I keep thinking that Hexadecimal goes 1, 8, 16, 32, 64, instead of 1, 16, 256, 163, etc.

                                    Thanks for pointing that out...

                                      bpat1434 wrote:

                                      Oh, okay.... for whatever reason, I keep thinking that Hexadecimal goes 1, 8, 16, 32, 64, instead of 1, 16, 256, 163, 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:

                                      [pre]
                                      s o g w
                                      - rwx rwx rwx = 777
                                      0 421 421 421 = binary -> decimal
                                      0 111 111 111 = binary
                                      [/pre]

                                      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>

                                        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 = 14+22+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)...

                                          Write a Reply...