I’m trying to memorize most of the PHP string and array functions, and trying not to refer to PHP manual all the time . The problem is, some of the functions takes haystack as the first parameter and takes needle as the second parameter, on the other hand, many functions takes needle as the first parameter and haystack as the second parameter, any advice how can we recognize these without referring to PHP manual every time
A question where they ask you the order of args in a string related function?
I don’t remember getting one, not even in all the mock tests I did. Maybe it was just me?
Theres just so much other stuff to get your head round, that really score highly in the ZCE tests. XML, OOP design patterns, Streams (ffs!).
FWIW you’d be better off memorizing the ~80 array functions, just know what they are called and what their subtle differences are. That was one area that has really made me a better PHPer - and they do feature highly in the ZCE.
The ZCE was much like the mocks, lots of sly tricky questions - many of which had a really simple answer - just make sure you get used to passing over them and pick off the easy questions first.
A general rule of thumb would be that for array functions, the order is needle, haystack; for string functions, the order is haystack, needle. There are exceptions of course and to save your memorising those, I’ll second the recommendation to use an IDE (or editor) which can give you the parameters as-you-type or at the click of a button/key. (:
This is why I believe the PHP function library needs a good rewrite, or at least the older parts of it. Newer functions have more of an order.
Personally, I’d say that your IDE can make a difference. I use eclipse PDT, and all I have to do is type ‘strpos’ then crtl+space, and it opens brackets for me and tells me what the parameter is ($haystack, $needle etc), sometimes with a description of the function too!