Dizenin başlangıcını 'http: //' ve '/' ve sonunu içerdiğinden emin olmanızı sağlayan normal ifadeye sahip olmak istiyorum. Ben bu iki ifade aşağıdaki gibi birlikte koyabilirsiniz düşüncepreg_match: başlangıç ve sonunun bir şey içerdiğinden emin olun
if(!preg_match("/(^http:\/\//", $site_http))
{
$error = true;
echo '<error elementid="site_http" message="site_http - Your link appears to be invalid. Please confirm that your link contains http:// at the start."/>';
}
elseif (!preg_match("/\/$/", $site_http))
{
$error = true;
echo '<error elementid="site_http" message="site_http - Your link appears to be invalid. Please confirm that your link has ended with a /."/>';
}
ama
Bu benim ile geldi daha uzun versiyonu, ama alışkanlık iş,
if(!preg_match("/(^http:\/\/)&(\/$)/", $site_http))
{
$error = true;
echo '<error elementid="site_http" message="site_http - Your link appears to be invalid. Please confirm that your link contains http:// at the start and a/at the end."/>';
}
birden ifadeleri ben birleştirmeye çalışın yanlış olmalı! Herhangi bir fikir?
sayesinde Lau ön
bir dize örneği verebilir:
aşağıdaki çıktıyı üretir? – Codex73