- preg_match: documentation ( source)
- sprintf: documentation ( source)
<?php
$paths = array(
'invalid path',
'/relative/path/image.jpg',
'http://myhost.com/image.jpg',
'https://mysslhost.com/image.jpg',
);
foreach ($paths as $path) {
$is_full_path = 0 !== preg_match('@^http(s)?:\/\/@', $path);
echo sprintf("'%s' %s is a full path.\n", $path, ($is_full_path ? 'YES' : 'NO'));
}