Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
Ev0luti0N каза:Ето по-добрият вариянт с preg_match:
PHP:$url = 'http://www.google.bg'; if (preg_match('/^(http|https):\/\/([a-z0-9-]\.+)*/i', $url)) { echo 'линк е'; } else { echo 'Не е линк"; }
/^(http|https):\/\/([a-z0-9-]\.+)*/
function check_url($url) {
if ( strlen( $url ) > 0 && function_exists( 'get_headers' ) ) {
$file_headers = @get_headers( $url );
$exists = $file_headers && $file_headers[0] != 'HTTP/1.1 404 Not Found';
}
return $exists ? true : false;
}
if(check_url('http://abobev.com') {
echo 'Линкът съществува';
} else {
echo 'Линкът НЕ съществува';
}
if ( strlen( $url ) > 0 && function_exists( 'get_headers' ) ) {
function file_type($kartinka){
$path_chunks = explode("/", $kartinka);
$thefile = $path_chunks[count($path_chunks) - 1];
$dotpos = strrpos($thefile, ".");
return strtolower(substr($thefile, $dotpos + 1));
}
function is_image($kartinka){
return ((in_array(file_type($kartinka), array('jpeg', 'jpg','png','gif'))) ? true : false);
}
if (is_image($url_na_kartinkata) == true) {
echo "Окей това е истинска картинка";
}
else { echo "Не, не става!"; }
<?php
header("Content-Type: text/html; charset=UTF-8");
$allowed_words = array("scheme" => array("http", "https"),
"path" => array(".jpg", ".jpeg", ".png", ".bmp", ".gif"));
$url = "http://www.example.com/index.gif";
$parseUrl = parse_url($url);
if((isset($parseUrl['scheme']) & isset($parseUrl['path'])) && in_array($parseUrl['scheme'], $allowed_words['scheme'])){
$cut_path_ext = stristr($parseUrl['path'], ".");
if(preg_match("/(www)?/i", $parseUrl['host']))
{
if(in_array($cut_path_ext, $allowed_words['path'])){
echo "Линк с картинка е!";
}
}
}
?>