Argument order
strstr($haystack, $needle);
explode($needle, $haystack);
str_replace($needle, $replace, $haystack);
Slide 17
Slide 17 text
Return values
⌁ not always what you think
⌁ manual isn't always clear
Slide 18
Slide 18 text
Return values
preg_match returns 1 if a pattern matches a given
subject, 0 if a pattern does not match a given
subject. Or false if there was an error.
Slide 19
Slide 19 text
Return values
preg_match returns 1 if a pattern matches a given
subject, 0 if a pattern does not match a given
subject. Or false if there was an error.
Slide 20
Slide 20 text
Return values
Oh, and by the way: "This function may return
Boolean FALSE, but may also return a non-
Boolean value which evaluates to FALSE..."
Slide 21
Slide 21 text
Return values
Oh, and by the way: "This function may return
Boolean FALSE, but may also return a non-
Boolean value which evaluates to FALSE..."
Slide 22
Slide 22 text
3 .Boxing
Slide 23
Slide 23 text
Boxing
⌁ classes wrap primatives
⌁ special construction
⌁ special deconstruction
Slide 24
Slide 24 text
Boxing
class StringObject {
protected $data;
public function __construct($data) {
$this->data = $data;
}
Slide 25
Slide 25 text
Boxing
public function value() {
return $this->data;
}
}
Slide 26
Slide 26 text
Boxing
$string = new StringObject("hello world");
$string->value(); // "hello world"
function value(StringObject $string) {
return $string->value();
}
Slide 27
Slide 27 text
Boxing
⌁ requires special construction and deconstruction
⌁ allows type-hinting