Zend php Certification exam tips-- strings Part I

· There should be no space before the ending statement of heredoc

· The only exception we can't use heredocs is in class properties:

class hello{

public $greeting=<<<>



} //parse error

· We can not escape a brace ({) in double quotes with a backslash. Instead, we should escape the dollar sign inside:


· strlen() is binary-safe. It means that counts all of the characters regardless of their value.

· \0 is counted once by strlen()

· Strtr() translates certain characters:

Form 1: string strtr(string str,string from, string to)

Form 2: string strtr(string str,array replace_pairs)

In Form1, to and from should be the same size.

· strcmp() and its family are extremely important in exam.

· Substr_compare() :

Int substr_compare(string main_str, string str, int offset[,int length[,bool case_insensitivity]])

Compares main_str from position offset with str up to length chars returns <0>

· Simplest way to search inside a string: strpos and strstr families

· Strstr is important. Read the manual carefully

· Strpos is important too. if needle is not found, strpos will return Boolean false. The important thing about strpos is that we should use === for comparison because if position was 0th char, then == interprets that as false.

· Case insensitive strstr: stristr

· Case insensitive strpos: stripos

· Strpos finds position of last occurrence of a char In a string:

echo strrpos('123123,'123"); //3