<?php
$input = 'http://#chrütli24/7schwur.ch';
$input = 'www.meinemüllerdomain.ch/index/checkMe?param#whatevs';
$pattern = array();
$pattern[] = '/\xE2\x80\x8B/';
$pattern[] = '/ /';
$pattern[] = '@^[a-z]+://@i';
$pattern[] = '/​/';
$pattern[] = '/\?/';
$pattern[] = '@^www\.@i';
// if entered, remove whitespaces, prepending protocoll and www.
$cleaned = preg_replace($pattern, null, idn_to_utf8(mb_strtolower($input, 'UTF-8')));
//echo $cleaned;
// if entered, remove trailing dot
$cleaned = (substr($cleaned, -1) == '.') ? substr($cleaned, 0, -1) : $cleaned;
//echo $cleaned;
if (strpos($cleaned, '@') !== false) {
echo 'false';
}
$val = filter_var(idn_to_ascii($cleaned), FILTER_VALIDATE_URL);
var_dump($val);
$correct = filter_var('http://'.$cleaned, FILTER_VALIDATE_URL);
var_dump($correct);
//var_dump(parse_url($correct));
$testdomain = idn_to_ascii($cleaned);
var_dump(filter_var($testdomain, FILTER_VALIDATE_URL));
preferences:
27.63 ms | 402 KiB | 5 Q