Tag Archives: Key Features of CMS

PHP Data Handling

Handling data

Every programming language has its own set of data types that help developers to write programs. A data type is a classification of data . This could mean categorizing the the type of data as an amount of money, time or percentage. In PHP the data type can be broadly classified as scalar and compounddata types.

Scalar data type

Four type of data comes under the category of scalar data type: Boolean, integer, float and string.

Boolean

The Boolean data type can either be true or false. The numeric representation of the Boolean data type is 1 for true and 0 for false. The the fallowing example uses this data type:

<?php
$myVal = True; // Boolean variable type.
?>

Integer

An integer data type consist of numbers. You can use both negative or positive numbers like […-2,-1,0,1,2,3,…]. The size of an integer in PHP solely depends on the operating system that you are using. typically , the size of an integer can be up to 2 billion. In the fallowing code, $myVal is aninteger type variable with a value of 9:

<?php
 $myVal =9; //Is an integer.
?>

Float

A float is a data type that is also use for storing numbers. Usually floats are use to express decimal numbers, you can use the integer data type for non decimal numbers. Floats are also known as doubles or real numbers and have a precision of up 14 decimal places. In the fallowing code ,$floatVal is a float type variable and has a value of 9.98765:

<?php
$ floatVal = 9.98765 // Is a float type variable
?>

String

A string can be best defined as a series of characters. In PHP, a character is nothing but a byte. There are 256 different types of characters that can be used in strings. There is no maximum limit specification in relation to strings to PHP; therefore you need not worry about a very long string .There are two ways to specify a string discussed on fallowing sections.

Single quoted

You can use single quotes to specify a simple string. How ever when a string is enclosed in single quotes and it also contains some text enclosed in double quotes, you must use the backslash escape character to escape the single quotes. In other wards when you don’t want to parser to treat single quotes as syntax and display them as part of the output of the code, you need o use a back slash beforethe single quotes.

Lets consider a simple example to understand how single quotes are used to specify a string:

<?php
      echo 'This is my First String'; // will print the string on the screen.
?>

Now consider an example where double quotes are used within single quotes and single quotes is represent in the text enclosed in double quotes:

echo 'Rishi says: "I'm doing well "'; , //will display error.

When you try to execute this statement, an error message will appear on the screen. This is because when you use a single quote within double quotes, you need to escape the single quote with a backslash. In the fallowing statement is written correctly:

echo 'Rishi says: "I\'m doing well "'; , //is Correct now.

The output will be Rishi says: “I’m doing well”.

Another thing that you should remember when using single quoted string is that such string don’t support variable expansion: If you use a name of variable within single quote and try to print the value of a variable, the name of the variable will be printed instead of its value. Consider the fallowing example:

<?php
  $name='Rishi';
  echo 'Hello $name';
?>

The output will be Hello $name.
The correct syntax is

<?php
  $name="Rishi";
  echo "Hello $name";
?>

The output will be Hello Rishi.

Double quoted

A double quoted strings supports several other escape characters as follows
– \n: new line
– \r: carriage
– \t: Horizontal tab
– \\: backslash
– \$: Dollar sign
– \”: Double quote

HTML Forms

HTML forms are used to send information to server. You can use input elements like text fields, radio buttons, check box, dropdown etc. to capture information. You can use multiple forms in a single HTML page, but you can’t use one form inside another form.

<form action="contact.php"></form>

Form and the Attribute:

Action: This attribute is used to send the information to the specified page. In the following page the value of all input filels will send to contact.php page.

<form action="contact.php"></form>

Autocomplete: As you start type in a input fields your browser history shows the previously enteredvalue, to avoid that you can set autocomplete off.

<form action="contact.php" autocomplete="off"></form>

Method: Method is use to set the send method of the form. It can either be GET or POST. To know more please click here.

<form action="contact.php" method="post"></form>

Name: Name attribute is used to assign a name to the form. It may required in JavaScript.

<form action="contact.php" method="post" name="myForm"></form>

HTML Forms Input Element

The Input elements are used to capture the user information.

<form action="contact.php" method="post" name="myForm">
<input type="text" />
</form>

Input and the Attribute:

Type: This attribute is use to define what type of element you want to display. It can be button, checkbox, file, hidden, image, password, radio, reset, submit or text.

<form action="contact.php" method="post" name="myForm">
<input type="text" />
</form>

Name: This is used to assign a name to the input fiel. Plese use unique name to each element in a form.

<form action="contact.php" method="post" name="myForm">
<input type="text" />
</form>

Value: This attribute is use to set the default value of an element.

<form action="contact.php" method="post" name="myForm">
<input type="text" value="Enter Name" />
</form>

You can also set the height, width of an text input field. And also assign calss and id to any input field.

HTML Links

Hyperlinks in HTML

Html hyperlink  is use to jump to any other page or to any other location in the current page. You can add hyperlink to any word or group of words or images. On mouse over any hyperlink your mouse courser change to a little hand. Links are specified in HTML using the <a> tag. To assign style to ahyperlink please visit CSS Tutorial.

HTML Link Syntax:

<a href="index.php">Home</a>

HTML – Link Targets

The attribute target use to set weather you want to open the link in a new window or in the same window.

Target
_blank Opens page in a new browser window/ New tab
_self Opens the page in same window
_parent Opens the page in the parent frame
_top Opens the page in same window, canceling all frames
<a href="index.php" target="_blank">Home</a>
<a href="index.php" target="_self">Home</a>
<a href="index.php" target="_parent">Home</a>
<a href="index.php" target="_top">Home</a>

HTML Email Link

<a href="mailto:a2zwebhelp@gmail.com">Contact Us</a>

Assign Subject and Body to HTML Email Link

<a href="mailto:a2zwebhelp@gmail.com?subject=my Question&body=Test">
Contact Us</a>

Default Links/ Base Link

The base tag used in the head element to set a default URL for all links on a page.

<head>
<base href="http://www.a2zwebhelp.com/" />
</head>

 

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 Lists

To create bulleted lines of text you can use HTML lists. Unordered lists (bullets), ordered lists (numbers) and definition lists (think: dictionaries) are three different types of HTML Lists.
Click here to know how to styling List in CSS.

Unordered lists (bullets): The <ul> tag

<ul>
   <li>HTML</li>
   <li>CSS</li>
   <li>Java Script</li>
   <li>PHP</li>
</ul>

The different type of Unordered list are square, circle and disc.

<ul type="square">
<ul type="circle">
<ul type="disc">

Numbered/Ordered List: The <ol> tag

<ol>
    <li>HTML</li>
    <li>CSS</li>
    <li>Java Script</li>
    <li>PHP</li>
</ol>

The different type of Numbered list are letters and Roman Numbers.

<ol type="a">
<ol type="A">
<ol type="i">
<ol type="I">

You can also change the start number

<ol start="7">

Definition Term Lists: The <dl> tag

<dl> – opening clause that defines the start of the list
<dt> – list item that defines the definition term
<dd> – definition of the list item

<dl>
   <dt>HTML</dt>
   <dd>- Hyper Text Markup Language</dd>
   <dt>CSS</dt>
   <dd>- Cascading Style Sheets</dd>
</dl>