Tôi muốn có cụm từ thông dụng để đảm bảo bắt đầu chuỗi chứa 'http: //' và '/' và kết thúc.preg_match: đảm bảo bắt đầu và kết thúc chứa nội dung nào đó
Đây là phiên bản còn tôi đã đưa ra,
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 /."/>';
}
nhưng tôi nghĩ rằng hai biểu thức này có thể đặt lại với nhau như dưới đây, nhưng nó wont work,
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."/>';
}
các biểu thức nhiều mà tôi cố gắng kết hợp phải sai! bất kỳ ý tưởng?
cảm ơn, Lau
Bạn có thể cung cấp một mẫu chuỗi? – Codex73