PHP Strings & Reg Exp Multiple Choice Questions

Which of the following will not combine strings $s1 and $s2 into a single string?

A) $s1 + $s2
B) "{$s1}{$s2}"
C) $s1.$s2
D) implode(' ', array($s1,$s2))
E) All of the above combine the strings

Given a variable $email containing the string, which of the following statements would extract the string

A) substr($email, strpos($email, "@"));
B) strstr($email, "@");
C) strchr($email, "@");
D) substr($email, strpos($email, "@")+1);
E) strrpos($email, "@");

Given a comma-separated list of values in a string, which function from the given list can create an array of each individual value with a single call?

A) strstr()
B) Cannot be done with a single function
C) extract()
D) explode()
E) strtok()

What is the best all-purpose way of comparing two strings?

A) Using the strpos function
B) Using the == operator
C) Using strcasecmp()
D) Using strcmp()

Which of the following PCRE regular expressions best matches the string php|architect?

A) .*
B) ...|.........
C) \d{3}\|\d{8}
D) [az]{3}\|[az]{9}
E) [a-z][a-z][a-z]\|\w{9}

Which of the following functions can be used to determine the integrity of a string?

A) md5()
B) sha1()
C) str_rot13()
D) crypt()
E) crc32()

What happens if you add a string to an integer using the + operator?

A) The interpreter outputs a type mismatch error
B) The string is converted to a number and added to the integer
C) The string is discarded and the integer is preserved
D) The integer and string are concatenated together in a new string
E) The integer is discarded and the string is preserved

The ___________ function can be used to compare two strings using a case-insensitive binary algorithm

A) strcmp()
B) stricmp()
C) strcasecmp()
D) stristr()
E) None of the above

Which of the following functions can be used to convert the binary data stored in a string into its hexadecimal representation?

A) encode_hex()
B) pack()
C) hex2bin()
D) bin2hex()
E) printf()

^[A-Za-z].* matches

A) play it again
B) I
C) 123
D) ?

^[0-9]{5}(\-[0-9]{4})?$ matches

A) 90001 and 90002-4323
B) 9001 and 12-4321