I’ve seen many people define an empty $matches
variable before using it in preg_match
and preg_match_all
functions in PHP. I’ve done it myself, and I was quite surprised to learn that you don’t really have to — even if there’s no match, you will not get an undefined variable notice.