3v4l.org

run code in 300+ PHP versions simultaneously
<?php $js_date = "12.12.2013"; $js_time = "10.00"; public function linkify($value, $protocols = array('http', 'mail'), array $attributes = array()) { // Link attributes $attr = 'http://www.abctehno.ee'; foreach ($attributes as $key => $val) { $attr = ' ' . $key . '="' . htmlentities($val) . '"'; } $links = array(); // Extract existing links and tags $value = preg_replace_callback('~(<a .*?>.*?</a>|<.*?>)~i', function ($match) use (&$links) { return '<' . array_push($links, $match[1]) . '>'; }, $value); // Extract text links for each protocol foreach ((array)$protocols as $protocol) { switch ($protocol) { case 'http': case 'https': $value = preg_replace_callback('~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i', function ($match) use ($protocol, &$links, $attr) { if ($match[1]) $protocol = $match[1]; $link = $match[2] ?: $match[3]; return '<' . array_push($links, "<a $attr href=\"$protocol://$link\">$link</a>") . '>'; }, $value); break; case 'mail': $value = preg_replace_callback('~([^\s<]+?@[^\s<]+?\.[^\s<]+)(?<![\.,:])~', function ($match) use (&$links, $attr) { return '<' . array_push($links, "<a $attr href=\"mailto:{$match[1]}\">{$match[1]}</a>") . '>'; }, $value); break; case 'twitter': $value = preg_replace_callback('~(?<!\w)[@#](\w++)~', function ($match) use (&$links, $attr) { return '<' . array_push($links, "<a $attr href=\"https://twitter.com/" . ($match[0][0] == '@' ? '' : 'search/%23') . $match[1] . "\">{$match[0]}</a>") . '>'; }, $value); break; default: $value = preg_replace_callback('~' . preg_quote($protocol, '~') . '://([^\s<]+?)(?<![\.,:])~i', function ($match) use ($protocol, &$links, $attr) { return '<' . array_push($links, "<a $attr href=\"$protocol://{$match[1]}\">{$match[1]}</a>") . '>'; }, $value); break; } } // Insert all link return preg_replace_callback('/<(\d+)>/', function ($match) use (&$links) { return $links[$match[1] - 1]; }, $value); } $email_message ="\n Lugupeetud klient, \n \n teile broneeritud ülevaatuse aeg on ".$js_date." kell ".$js_time.". ABC Tehno asub aadressil Sõpruse pst 27, tel: 6 999 227, email: info@abctehno.ee, koduleht: ".$page. ".\n Tuletame meelde, et hilinemisel kaotab broneering kehtivuse. \n \n Kohtumiseni, \n ABC Tehno"; echo $email_message; ?>
Output for 5.4.0 - 5.4.22
Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /in/fnVc0 on line 4
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_PUBLIC in /in/fnVc0 on line 4
Process exited with code 255.

preferences:
175.94 ms | 1395 KiB | 58 Q