Using experimental feature: HTML5 Conformance Checker

The warning “Using experimental feature: HTML5 Conformance Checker.” means that the validator is checking your markup as HTML5. It doesn’t mean that there is anything wrong with the code. But W3C hasn’t accepted HTML5 as a standard, so validator provides a warning for that, because HTML5 standard is not complete yet. So it is recommended to validating with doctype of  “HTML 4.01 Strict”.

For more information about Recommended list of Doctype declarations, visit this link.

Get Response Header from file_get_contents in PHP

file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.

A URL can be used as a filename with this function if the fopen wrappers have been enabled.

But, reading URL becomes difficult to identify that URL is not available. And if URL is not available, it’s also difficult to process that URL. So, it is necessary that there is a response for every request fired by file_get_contents() for any URL.

PHP has a predefined variable named $http_response_header, which provides a response header for any HTTP request sent by PHP code.

For Example,

file_get_contents("http://example.com");
var_dump($http_response_header);

The above example will output something similar to:

array(9) {
  [0]=>
  string(15) "HTTP/1.1 200 OK"
  [1]=>
  string(35) "Date: Sat, 12 Apr 2008 17:30:38 GMT"
  [2]=>
  string(29) "Server: Apache/2.2.3 (CentOS)"
  [3]=>
  string(44) "Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT"
  [4]=>
  string(27) "ETag: "280100-1b6-80bfd280""
  [5]=>
  string(20) "Accept-Ranges: bytes"
  [6]=>
  string(19) "Content-Length: 438"
  [7]=>
  string(17) "Connection: close"
  [8]=>
  string(38) "Content-Type: text/html; charset=UTF-8"
}

Note that the HTTP wrapper has a hard limit of 1024 characters for the header lines.
Any HTTP header received that is longer than this will be ignored and won’t appear in $http_response_header.

The cURL extension doesn’t have this limit.

Different YouTube video thumbnail URLs

To get the different thumbnails of embedded video from YouTube, use these image URLs for different dimensions,

1) For medium sized thumbnail image
http://i.ytimg.com/vi/<YouTube Video ID>/0.jpg

2)  For small sized thumbnail image

http://i.ytimg.com/vi/<YouTube Video ID>/1.jpg
http://i.ytimg.com/vi/<YouTube Video ID>/2.jpg
http://i.ytimg.com/vi/<YouTube Video ID>/3.jpg

3) For large or maximum sized thumbnail image

http://i.ytimg.com/vi/<YouTube Video ID>/maxresdefault.jpg

4) For High Definition Image

http://img.youtube.com/vi/<YouTube Video ID>/hqdefault.jpg

In above URLs, provide <YouTube Video ID>. To get Video ID from YouTube URL,

  • Go to http://www.youtube.com
  • Play any video
  • Copy an alphanumeric string followed by v= from URL

This is a Video ID of currently playing video.

For example:

Video ID of YouTube Video https://www.youtube.com/watch?v=ny8ngucMd_U is ny8ngucMd_U

Use this video ID in above thumbnail URLs to get different thumbnail image of this video.

Find YouTube Video ID from YouTube URL

YouTube has so many types of URLs to embed the video on your site. Sometimes it’s difficult to find a single regular expression to parse all type of YouTube URL and retrieve the video ID from it.

YouTube has so many types of URLs to embed the video on your site. Sometimes it’s difficult to find a single regular expression to parse all type of YouTube URL and retrieve the video ID from it.

To retrieve the video ID from the YouTube URL, use this function,

function getVideoID($url) {
    $pattern = '#^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v=|/watch\?.+&v=))([\w-]{11})(?:.+)?$#x';
    preg_match($pattern, $url, $matches);
    return (isset($matches[1])) ? $matches[1] : false;
}

Regular Expression explanation is as follows,

$pattern = '#^(?:https?://)?';    # Either http or https.
$pattern .= '(?:www\.)?';         #  Optional, www subdomain.
$pattern .= '(?:';                #  Group host alternatives:
$pattern .=   'youtu\.be/';       #    Either youtu.be,
$pattern .=   '|youtube\.com';    #    or youtube.com
$pattern .=   '(?:';              #    Group path alternatives:
$pattern .=     '/embed/';        #      Either /embed/,
$pattern .=     '|/v/';           #      or /v/,
$pattern .=     '|/watch\?v=';    #      or /watch?v=,    
$pattern .=     '|/watch\?.+&v='; #      or /watch?other_param&v=
$pattern .=   ')';                #    End path alternatives.
$pattern .= ')';                  #  End host alternatives.
$pattern .= '([\w-]{11})';        # Youtube video ids with standard length of 11 chars.
$pattern .= '(?:.+)?$#x';         # Optional other ending URL parameters.

cPanel SoftException: GID of script is smaller than min_gid

After upgrading EasyApache in WHM, sometimes it gives 500 (Internal Server Error) error in the browser.  If you check the error_log file, you find:

SoftException in Application.cpp:363: GID of script "/home/current_user/public_html/index.php" is smaller than min_gid

OR

SoftException in Application.cpp:363: UID of script "/home/current_user/public_html/index.php" is smaller than min_uid

If you check the permission of user/group for this file, it gives you root. So, apache can’t read these files uploaded by the root user. One solution is to change the permission of user/group to your current user.

chown current_user:current_user /home/current_user/public_html/ -R

This will solve the permission related issue on your site.

References :
http://www.flynsarmy.com/2011/10/cpanel-softexception-uid-is-smaller-than-min_uid/
http://forums.eukhost.com/f15/how-solve-error-softexception-application-cpp-303-a-6205/