Skip to content

Commit 49de4f6

Browse files
Make convertEmail PHP 5.3 Compatible
1 parent 139986a commit 49de4f6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Autolink.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,21 @@ function($matches) use ($self, $attribs)
101101
*/
102102
public function convertEmail($text, $attribs = array())
103103
{
104+
$self = $this;
105+
104106
$regex = "/(([a-zA-Z]*=\")*\S+@\S+\.\S+)/";
105107

106108
return preg_replace_callback(
107109
$regex,
108-
function($matches) use ($attribs)
110+
function($matches) use ($self, $attribs)
109111
{
110112
preg_match('/[a-zA-Z]*\=\"(.*)/', $matches[0], $inElements);
111113

112114
if (!$inElements)
113115
{
114116
$attribs['href'] = 'mailto:' . htmlspecialchars($matches[0]);
115117

116-
return $this->buildLink($matches[0], $attribs);
118+
return $self->buildLink($matches[0], $attribs);
117119
}
118120

119121
return $matches[0];

0 commit comments

Comments
 (0)