Tag Archives: chrome extension

PHP Compound Data Type

PHP consist of two compound types, arrays and objects.

Arrays

Arrays are special types of variables that can store more than one value. Arrays are useful when you need to store related variables data under one variable name.

An array can be declare in fallowing way:

$arr-name [key]= value;

In the above statement
arr_name is the name of the array.
Key is any string or a non negative integer. if you want to modify an array, it is best not to specify a key and to leave the square bracket empty.
Value is the data that is held in the array.

To understand the concept arrays, consider the fallowing codes:

<?php
$arr_name[0]="My";
$arr_name[1]="name";
$arr_name[2]="is";
$arr_name[3]="Rishi";
echo "$arr_name[0] $arr_name[1] $arr_name[2] $arr_name[3] $arr_name[4]";
?>

Output of the above code is: My name is Rishi

Objects

Objects are are the building blocks of a programming language . An object is an entity that can hold data and specify what need to be done with the data. Most of the internal working of an object are hidden from the code that uses them. Objects are a bundle of variable and functions that are derived from a class. To understand the concept of object you should be familiar with the fallowing terminology

Object orientation

The programming concept that revolves around objects.An object is an instance of a class.

Class.

A class is an entity that exibit certain behavior and expose certain attributes to retain state.

Properties

The character of an object defined by the class to which it belongs.

Methods

Task that can be performed by object on the data they contain.

Juggling Data Types

PHP does not require the developer to absolutely specify a data type for a variable at the time ofdeclaration. In PHP you need not worry about data type mismatches in an expression. Consider the fallowing example:

<?php
 $myVal = 7+ "2 is my number";
 echo $myVal;
?>

The output will be: 9.

In most other language ,the preceding code will not be valid. In PHP this statement is valid, and it also generates the expected output. This is because in PHP a variable doesn’t have fixed data type assign to it and can store any data type. The result of an expression is calculated on the basic of the operator and not on the basic of the operands. Examine the fallowing code for a better understanding of juggling data type:

<?php
  $a = "Rishi";
  $a +=2; // The += operator is use to add the initial value assigned to
// the variable to the number specified.r>  echo?>

The output will be : 2

In the above example ,$a contains a value that is of the string data type. In the next line, the += operator changes the initial variable assigned to $a to 2.

Consider another example where the .= operator is used to concatenate string:

<?php
 $a = "Rishi";r>  $a .=2; //The .= operator is use to concatenate two string .
 echo $a; //The value of $a is now Rishi2 
?>

The output will be: Rishi2

The . = operator tells the PHP that the number 2 is a string even though it is not specified in single quotes or double quotes. As a result it concatenates the initial value with the new value of $a, and the output is Rishi2.

Constants

A constant is a name that identifies a simple value. By nature, a constant is the opposite of a variable because the value of a constant remains fixed and doesn’t change when the script is executed. Constant have the fallowing characteristics:
– A constant is case sensitive by default.
– By convention, constant are expressed in uppercase letters.
– A consent can begin with either an underscore or with a letter, fallowed by any number of underscore, letters or numbers.

There are several other differences between variable and constants:

– A constant name never begins with a dollar sign .
– After a constant is set, it is not possible to to redefine or undefined it.
– A constant can contain only scalar data type like : Boolean, integer, float and string.
– A constant can be accessed and use anywhere in a script regardless of variable scoping rules.

Defining constants

A simple way to define a constant by using the define ( ) function. After you define a constant, you can read it’s value anytime you want by simply using it’s name. To read a constant value you can use the constant ( ) function. To obtained a list of all defined coinstants, you can use the get-defined-constants function.
In the fallowing code, a constant ADMIN_MAIL is defined with the value “contatc@a2zwebhelp.com”. Notice that constants are case sensitive, and the value assigned to the constant ADMIN_MAIL doesn’t appear when you try to print the value of the constant admin_mail:

<?php
    define ("ADMIN_MAIL" ,"contatc@a2zwebhelp.com");
  echo MIN_MAIL;
?>

The output will be: contatc@a2zwebhelp.com

HTML iframe

Ifrems are used to show website inside a HTML page.

<iframe src="URL"></iframe>

Iframe and the Attribute:

Align: You can use left, right, top, middle or bottom to align the Iframe.

<iframe src="URL" align="left"></iframe>

Frameborder: You can use 0/1 to hide or display frame border. You can also use no/ yes.

<iframe src="URL" align="left" frameborder="0"></iframe>

Height: You can set iframe height either in pixel (px) or percentage(%).

<iframe src="URL" align="left" height="250px"></iframe>

Marginheight: You can set iframe top and bottom margin in pixel for contents inside an iframe with the help of marginheight.

<iframe src="URL" align="left" marginheight="20px"></iframe>

Marginwidth: You can set iframe left and right margin in pixel for contents inside an iframe with the help of marginheight.

<iframe src="URL" align="left" marginwidth="50px"></iframe>

Name: Name attribute is used to assign a name to the iframe.

<iframe src="URL" align="left" name="myFrame"></iframe>

Scrolling: You can show/ hide the scrollbar of the iframe. The value are yes, no or auto.

<iframe src="URL" align="left" scrolling="no"></iframe>

Width: You can set iframe width either in pixel (px) or percentage(%).

<iframe src="URL" align="left" width="100%"></iframe>

 

HTML Video

Play Video in HTML Page

You can add audio or video to your html page. Either you can add video from www.youtube.com or you can add you own video by uploading the same to your own web server. But it is a bit tricky to show videos in your web page, and it is a little complicated to make it works in all browser.

Browser Supported Video Formats:

File Format
.swf or .flv Flash
.mov QuickTime
.rm or .ram Real Video
.avi AVI
.wmv WMV
.mpg or .mpeg MPEG
.mp4 Mpeg-4

Play Flash File in HTML Page

<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" 
id="obj1" border="0" width="160" height="160">
<param name="movie" value="myfile.swf">
<param name="quality" value="High">
<param name="wmode" value="transparent">
<embed src="myfile.swf" 
type="application/x-shockwave-flash" 
name="obj1" width="160" height="160" 
quality="High" wmode="transparent"></object>

Play QuickTime in HTML Page

<embed src="mymovie.mov" width="320" height="252" 
autoplay="true" controller="true" loop="false" 
pluginspage="http://www.apple.com/quicktime/">

Play RealVideo in HTML Page

<object id="id1" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" 
height="240" width="320">
<param name="controls" value="imagewindow">
<param name="autostart" value="true">
<param name="src" value="myvideo.rm">
<embed height="240" width="320" controls="imagewindow" src="myvideo.rm" 
type="audio/x-pn-realaudio-plugin" autostart=true>
</object>

Play MPEG Video in HTML Page

<embed src="myfile.mpeg" autostart="false" />

Play Youtube Video in HTML Page

<iframe width="420" height="315" 
src="http://www.youtube.com/embed/p9KjdYJ_gcc" 
frameborder="0" allowfullscreen></iframe>
<object width="420" height="315">
<param name="movie" 
value="http://www.youtube.com/v/p9KjdYJ_gcc?version=3&amp;hl=en_US">
</param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/p9KjdYJ_gcc?version=3&amp;hl=en_US" 
type="application/x-shockwave-flash" width="420" height="315" 
allowscriptaccess="always" allowfullscreen="true"></embed>
</object>

 

HTML Images

To show images in your HTML pages, you can use <img> tag. You can use .jpg, .gif, .png images in you web page. Always use compress image like jpg, gif and png images for faster loading and betterresults.

Img tag and it’s Attributes:

Src: This is used to define the path of the image file that you want to show in your web page.

<img src="path2yourfile.gif">

Align: You can set alignment of the image like leftright or center.

 <img src="path2yourfile.gif" align="left">

Alt: Alternate text. For any case if the image can’t display in the web browser the alt text will disply in place of the image. This is also required for SEO (Search Engine Optimization).

 <img src="path2yourfile.gif" alt="this is my image">

Border: This element used to define the border of the image. You can use border=”0″ (Zero) to display no border.

 <img src="path2yourfile.gif" border="0">

Class: You can also assign CSS class to any image with the help of class attribute.

 <img src="path2yourfile.gif">

Height: This attribute is used to define the height of an image.

 <img src="path2yourfile.gif" height="50px">

Id: You can set any unique id of an image for programming use with the help of ID attribute.

 <img src="path2yourfile.gif" id="uid3">

Width: This attribute is used to define the width of an image.

 <img src="path2yourfile.gif" width="100px">

Title: This attribute is used to define the Title of an image. On mouse over the image the title of the image will display. This is an optional option, but it is also helpfull for SEO.

 <img src="path2yourfile.gif" title="Image title here">

Hyperlink of an image

<a href="mypage.html"><img src="file.gif" border="0"></a>

 

HTML5 Elements

In the previous chapter we have discussed about some of the basic HTML 4 elements. Apart form those HTML 5 has introduced some other useful elements and tags and also some of the old elements removed in HTML 5. Let’s discuss those in detail.

HTML 5 New Elements

<canvas>
<details>
<datagrid>
<menu>
<summary> Defines a visible heading for a <details> element
<mark>  to indicate content that is marked in some fashion
<time>  to indicate content that is a time or date
<meter>  to indicate content that is a fraction of a known range – such as disk usage
<progress>  to indicate the progress of a task towards completion
<wbr>

HTML 5 Media Elements

<audio>
<video>
<source>
<embed>
<track>

HTML 5 Form Input Type

datetime
datetime-local
date
month
week
time
number
range

email
url

(Click here for more detail about HTML 5 form elements and input types)

Some elements removed in HTML 5

  • acronym
  • applet
  • basefont
  • big
  • center
  • dir
  • font
  • frame
  • frameset
  • isindex
  • noframes
  • noscript
  • strike
  • tt