3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $strings[] = "http://t.me/tm_factory_bot"; //0 $strings[] = "https://telegram.me/tm_factory_bot"; //1 $strings[] = "https://telegram.me/tm_factory_bot?start=123"; //2 $strings[] = "tg://resolve?domain=buy_this"; //3 $strings[] = "tg://resolve?domain=buy_this&start=123"; //4 $strings[] = "https://t.me/joinchat/AAAAAEOI5lHxvYlMxwHGSA"; //5 $strings[] = "https://web.telegram.org/#/im?tgaddr=tg%3A%2F%2Fjoin%3Finvite%3DAAAAAEOI5lHxvYlMxwH-GSA"; //6 $strings[] = "https://web.telegram.org/#/im?tgaddr=tg%3A%2F%2Fresolve%3Fdomain%3Dbuy_this"; //7 $strings[] = "https://web.telegram.org/#/im?tgaddr=tg%3A%2F%2Fresolve%3Fdomain%3Dtm_factory_bot%26start%3D123"; //8 $strings[] = "https://web.telegram.org/#/im?p=@funny_images"; //9 $strings[] = "@funny_images"; //10 $strings[] = "funny_images"; //11 $strings[] = "tg://join?invite=AAAAAEOI5lHxvYlMxwHGSA"; //12 foreach ($strings as $key=>$string) { $tgType = true; if ($tgType) { $private = "tg://join?invite="; $public = "tg://resolve?domain="; $sep = "&"; } else { $private = "https://t.me/joinchat/"; $public = "https://t.me/"; $sep = "?"; } $value = urldecode($string); preg_match('#[^&\?]??([a-z_0-9\-]+)[&\?]??(start=[a-z0-9]*?)?$#i', $value, $preg); if (preg_match("#(invite=|joinchat/)#i", $value)) { $link = $private . $preg[1]; } else { $link = $public . $preg[1]; } if (isset($preg[2])) { $link .= $sep . $preg[2]; } echo "\r\n" . $key . " - " . $link; }
based on bTZiG
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.3.0alpha1
0 - tg://resolve?domain=tm_factory_bot 1 - tg://resolve?domain=tm_factory_bot 2 - tg://resolve?domain=tm_factory_bot&start=123 3 - tg://resolve?domain=buy_this 4 - tg://resolve?domain=buy_this&start=123 5 - tg://join?invite=AAAAAEOI5lHxvYlMxwHGSA 6 - tg://join?invite=AAAAAEOI5lHxvYlMxwH-GSA 7 - tg://resolve?domain=buy_this 8 - tg://resolve?domain=tm_factory_bot&start=123 9 - tg://resolve?domain=funny_images 10 - tg://resolve?domain=funny_images 11 - tg://resolve?domain=funny_images 12 - tg://join?invite=AAAAAEOI5lHxvYlMxwHGSA