<!doctype html>
<html lang="en">
<head>
<title>The jQuery Example</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
</head>

<body>
<div>
<p class="myclass">This is a paragraph.<p>
<p id="myid">This is second paragraph.<p>
<p>This is third paragraph.<p>
</div>
</body>

<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {

$("p").css("background-color", "yellow");

});
</script>
</html>
.section {
text-align:center;
}

a:hover {
outline: 0;
}

#myVideo {
position: absolute;
z-index: 4;
right: 0;
bottom: 0;
top: 0;
right: 0;
width: 100%;
height: 100%;
background-size: 100% 100%;
background-color: black; /* in case the video doesn't fit the whole page*/
background-image: /* our video */;
background-position: center center;
object-fit: cover; /*cover video background */
}

#section1 .layer {
position: absolute;
z-index: 5;
width: 100%;
left: 0;
top: 43%;
height: 100%;
}

#section1 h1 {
color:#fff;
}

#infoMenu li a {
color:#fff;
}

/* If you want to change the case of a set of text to a specific case, use these CSS examples: */

text-transform: uppercase;
text-transform: lowercase;
text-transform: capitalize;

/* duration | timing-function | delay | iteration-count | direction | fill-mode | play-state | name */
animation: 3s ease-in 1s 2 reverse both paused slidein;
$(document).ready(function() {
$("p").css("background-color","yellow");
});

$("a").click(function(event) {
alert("Thanks for visiting!");
});

/* Hover on/off element */
$("#selector").hover(function() {
$(this).css("cursor","pointer");
}, function() {
$(this).css("cursor","auto");
});

/* Below is a brief overview of some of the most commonly used selectors. */

$("*") - Wildcard: /* selects every element on the page. */
$(this) - Current: /* selects the current element being operated on within a function. */
$("p") - Tag: /* selects every instance of the <p> tag. */
$(".example") - Class: /* selects every element that has the example class applied to it. */
$("#example") - Id: /* selects a single instance of the unique example id. */
$("[type='text']") - Attribute: /* selects any element with text applied to the type attribute. */
$("p:first-of-type") - Pseudo Element: /* selects the first <p>. */
function getAge($birthdate = '0000-00-00') {
if ($birthdate == '0000-00-00') return 'Unknown';

$bits = explode('-', $birthdate);
$age = date('Y') - $bits[0] - 1;

$arr[1] = 'm';
$arr[2] = 'd';

for ($i = 1; $arr[$i]; $i++) {
$n = date($arr[$i]);
if ($n < $bits[$i])
break;
if ($n > $bits[$i]) {
++$age;
break;
}
}
return $age;
}

// This function is to get age by given birthday (format: YYYY-MM-DD)
function pdfToJpg($pdf, $jpg) {
$im = new Imagick();
$im->setResolution(300,300);
$im->readimage($pdf);
$im->setImageFormat('jpeg');
$im->writeImage($jpg);
$im->clear();
$im->destroy();
}

/* SYNTAX */
/*
This function is to convert PDF files into image file. It takes two params:
string $pdf – Path to the initial PDF file
string $jpg – Path to the image file
*/
$useragent = $_SERVER ['HTTP_USER_AGENT'];
echo "Your User Agent is: " . $useragent;
function base64url_encode($plainText) {
$base64 = base64_encode($plainText);
$base64url = strtr($base64, '+/=', '-_,');
return $base64url;
}

function base64url_decode($plainText) {
$base64url = strtr($plainText, '-_,', '+/=');
$base64 = base64_decode($base64url);
return $base64;
}
function secsToStr($secs) {
if($secs >= 86400) {
$days = floor($secs/86400);
$secs = $secs%86400;
$r = $days . ' day';
if($days <> 1) {
$r .= 's';
}
if($secs>0) {
$r .= ', ';
}
}
if($secs >= 3600) {
$hours = floor($secs/3600);
$secs = $secs%3600;
$r .= $hours . ' hour';
if($hours <> 1) {
$r.='s';
}
if($secs > 0) {
$r .= ', ';
}
}
if($secs >= 60) {
$minutes = floor($secs/60);
$secs = $secs%60;
$r .= $minutes . ' minute';
if($minutes <> 1) {
$r.='s';
}
if($secs > 0) {
$r .= ', ';
}
}
$r .= $secs . ' second';
if($secs <> 1) {
$r .= 's';
}
return $r;
}

/* SYNTAX */
/*
$seconds = "56789";
$output = secsToStr($seconds);
echo $output;
*/
function hextorgb($hexvalue) {
if($hexvalue[0] == '#') {
$hexvalue = substr( $hexvalue, 1);
}
if(strlen( $hexvalue ) == 6) {
list($r, $g, $b) = array($hexvalue[0] . $hexvalue[1], $hexvalue[2] . $hexvalue[3], $hexvalue[4] . $hexvalue[5]);
}
elseif (strlen($hexvalue) == 3) {
list($r,$g,$b) = array($hexvalue[0] . $hexvalue[0], $hexvalue[1] . $hexvalue[1], $hexvalue[2] . $hexvalue[2]);
}
else {
return false;
}
$r = hexdec($r);
$g = hexdec($g);
$b = hexdec($b);
return array('R' => $r, 'G' => $g, 'B' => $b);
}

/* SYNTAX */
/*
$rgb = hextorgb('#fff000');
print_r($rgb);
*/
//generates a random password which contains all letters
//(both uppercase and lowercase) and all numbers

function generatePassword($length) {
$password = "";

for ($i = 0; $i <= $length; $i++) {
$chr = "";
switch (mt_rand(1, 3)) {
case 1:
$chr = chr(mt_rand(48, 57));
break;
case 2:
$chr = chr(mt_rand(65, 90));
break;
case 3:
$chr = chr(mt_rand(97, 122));
break;
}
$password .= $chr;
}
return $password;
}
function list_files($dir)
{
if(is_dir($dir))
{
if($handle = opendir($dir))
{
while(($file = readdir($handle)) !== false)
{
if($file != "." && $file != ".." && $file != "Thumbs.db"/*pesky windows, images..*/)
{
echo " " . $file . " " . "\n";
}
}
closedir($handle);
}
}
}

/* SYNTAX */
/*
list_files("images/");
*/
// we connect to example.com and port 3307
$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);

// we connect to localhost at port 3307
$link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
function ordinal($cdnl){ 
$test_c = abs($cdnl) % 10;
$ext = ((abs($cdnl) %100 < 21 && abs($cdnl) %100 > 4) ? 'th'
: (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1)
? 'th' : 'st' : 'nd' : 'rd' : 'th'));
return $cdnl.$ext;
}

/* SYNTAX */
/*
$number = 10;
echo ordinal($number); //output is 10th
*/
function getRealIpAddr()  
{
if (!empty($_SERVER['HTTP_CLIENT_IP']))
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
//to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
My code blog is a great place to store and share code snippets, just like this favourite JQuery one.

Apply this to any element to create a mouse over effect
that changes the mouse pointer to hand and back again.
$("#selector").hover(function() {
$(this).css('cursor','pointer');
}, function() {
$(this).css('cursor','auto');
});

See it in action!

Hover Me!
GnasheR's Snippets
GnasheR

PHP as it's known today is actually the successor to a product named PHP/FI. Created in 1994 by Rasmus Lerdorf, the very first incarnation of PHP was a simple set of Common Gateway Interface (CGI) binaries written in the C programming language. Originally used for tracking visits to his online resume, he named the suite of scripts "Personal Home Page Tools," more frequently referenced as "PHP Tools." Over time, more functionality was desired, and Rasmus rewrote PHP Tools, producing a much larger and richer implementation. This new model was capable of database interaction and more, providing a framework upon which users could develop simple dynamic web applications such as guestbooks. In June of 1995, Rasmus released the source code for PHP Tools to the public, which allowed developers to use it as they saw fit. This also permitted and encouraged users to provide fixes for bugs in the code, and to generally improve upon it.
Go To Top