Logo

Programming-Idioms

History of Idiom 96 > diff from v20 to v21

Edit summary for version 21 by :
[PHP] Comments: where is prefix

Version 20

2016-02-23, 13:37:14

Version 21

2016-02-23, 21:03:32

Idiom #96 Check string prefix

Set boolean b to true if string s starts with prefix prefix, false otherwise.

Idiom #96 Check string prefix

Set boolean b to true if string s starts with prefix prefix, false otherwise.

Code
$s = "http://asdf.com";
$b = (bool)preg_match('#^http#', $s);
Code
$b = (bool)preg_match('#^http#', $s);
Comments bubble
But what about a variable $prefix (not a constant) ?