> 2013 ~ Online tutorial

75% discount Hosting plan sale in Hostgator

75% discount Hosting plan sale in Hostgator

HostGator is one of the world's top 10 largest web hosting companies and offers the Black friday offer today.
Offer In Hostgator

Hostgator is offering 1 hour flash sale on Black friday, and you can grab hosting for as low as $1.24/month.
Discount: Various discount from Black friday to Cyber monday.
Start date: Today
End date: December 2nd


Click To Get

PHP interview Question with answer

PHP interview Question with answer

1)<?php
$varA=one;
$varB=&$varA;
$varA=two;
print $varB;
?>

Output:
2

It is result is Two because $varB holds the reference of $varA value an dboth $varA and $varB poin the same value.

2)<?php
$num1=6;
$num2=5;
$val=(num1>$num2)?$num1:$num2;
echo "Greatest of no".$val;num2;
?>

Output:
6
It is greatest of two number in the given number.

3)what is print_r()?

The print_r() is used to print out the entire content of array.
<?php
$fruit=array("orange","apple","mango");
print_r($fruit);
?>

4)What happened below code
<?php
print "type(152).gettype(152)."\n";
?>

Answer:

it is return the 152 as an Integer value.gettype() is used to get the datatype.

5)How do find the Ip address of remote machine?

Answer:

<?php
echo "your ip address is ".$SERVER['REMOTE_ADDR'];
?>

6)<?php
echo ucfirst("helloworld");
?>
what happened in this code?

Answer:

It is return the output Hello world.the ucfirst() is used to convert the first character in to Uppercase.

7)Difference between include() and require()?

In include() function if can't include the file it is generate error but continue the execution of program but require() function if can't include the file it is generate fatal error in script.

8)How destroy the session in PHP?

In session we are using unset() or session_destroy() function which is used to destroy the session in PHP.

9)What is use of explode() in PHP?
explode() function is used to convert string into array.

10)How do connect PHP with Mysql query?

$mysql_connect("address","username","password")

How do Upload File using PHP

How do Upload File using PHP

In PHP we are using two file which used upload file in the server.First one Html file and another one is PHP file .

In the Html file we are going get file content and PHP file we are process it and Upload into Particular file path.

Coding

In the coding section we are show First html file.In the html file we are going to get file and sent to php file using POST method.Here code for HTML file.


Upload.html:

1)In the form enctype/form data encding when submitting to the server.


<html>
<body>
<form enctype="multipart/formdata" action="saveupload.php" method="post">
<input type="file" name="fileToUpload">
<input type="submit" value="UploadFile">
</form>
</body>
</html>

saveupload.php:


1)$_FILES["file"]["name"] it is used get the name of file
2)$_FILES["file"]["type"] it is used to get type of file  
3)$_FILES["file"]["size"]  it is used to get size of file 
4)$_FILES["file"]["tmp_name"]  it is give tmp name of file which is ued to store the file in folder.


<?php

echo "<table border=\"1\">";
echo "<tr><td>Client Filename: </td>

   <td>" . $_FILES["file"]["name"] . "</td></tr>";

echo "<tr><td>File Type: </td>
   <td>" . $_FILES["file"]["type"] . "</td></tr>";
echo "<tr><td>File Size: </td>
   <td>" . ($_FILES["file"]["size"] / 1024) . " Kb</td></tr>";
echo "<tr><td>Name of Temp File: </td>
   <td>" . $_FILES["file"]["tmp_name"] . "</td></tr>";
echo "</table>";

move_uploaded_file($_FILES["file"]["tmp_name"], "C:/upload/" . $_FILES["file"]["name"]);

?>

move_uploaded_file(dest_file,source_file)

Here Upload is folder we can create in you local computer it is save the file. 

change button color in javascript

change button color in javascript

In the program we will show you How do change button color using javascript .In javascript we are using onmouseover it is used to record mouse move.


Source code




<html>
<head>
<script type="text/javascript">
function changeColor(color)
{
document.getElementById('MyButton').style.background=color;
}
</script>
</head>
<body>
<p>Move mouse over the color string</p>
<table width="60%">
<tr>
<td bgcolor='red' onmouseover="changeColor('red')">RED</td>

<td bgcolor='yellow' onmouseover="changeColor('yellow')">YELLOW</td>

<td bgcolor='aqua' onmouseover="changeColor('aqua')">AQUA</td>
</tr>
</table>
<form>
<input id="MyButton" type="button" value='changing color of buttons'>
</form>
</body>
</html>

How do search word in string using javascript


How do search word in string using javascript


In program we will show How do get word from given string using java script.When you are using search keyword it is searching word in the given string if it is found then return 0 otherwise not return any value.

Program


<html>
<head>
<script type="text/javascript">
function test()
{
document.write("The given String is");
document.write("<em>"+str+"</em>");
var i=str.search(/like/);
return i;
}
</script>
</head>
<body>
<h3>
<script type="text/javascript">
var index=test("I like programming");
if(index>0)
document.write("The match is found"+"<em>"+"like"+"<em>");
else
document.write("The match is not found");
</script>
</h3>
</body>
</html>

Output

The given String is
I like programmingThe match is foundlike



How do get server date using PHP

How do get server date using PHP

In this program i will show you how do get server date and time using PHP.In PHP getdate() function is used to get date in server.

Program

<?php
$time = getdate();
$date = $time['day'];
$month = $time['month'];
$year = $time['year'];
$hour = $time['hours'];
$min = $time['minutes'];
$sec = $time['seconds'];

$current_date = "$date/$month/$year == $hour:$min:$sec";

echo "$current_date";

?>


Output:



How do get month using javascript

How do Get month using javascript

In the java script we can using getMonth() function which is used to get current month.

Program



<html>
<body>
<script type="text/javascript">
d=new Date();
ch=d.getMonth();
document.write(ch);
</script>
</body>
<html>
Output:


In this program The program will return only numeric value if it is 2 then month is march so you can using this is coding you can find current month.

Pop up box in javascript

Pop up box in java script

In this below coding is used to show How do create popup box using javascript.
Alert box:In this type of pop up box some message will be displayed
confirm box:In this type of popup box in which message about confimation will be displayed
Prompt boxIn is a type of popup box which display text window in which user can enter something Hence it has two buttons OK or cancel




Program


<html>
<body>
<script type="text/javascript">
if(confirm("do you agrred?"))
alert("You have agreed");
else
input_text=prompt("Enter some string here," ");
alert("hi"+input_text);
</script>
</body>
</html>





make image using php

make image using php

In this program we will create image using php.In the imagecreate is used to create the image space.


<?php
header("Content-Type: image/png");

$im = @imagecreate(500, 120)

or die("Cannot Initialize new GD image stream");

$background_color = imagecolorallocate($im, 0, 0, 0);

$text_color = imagecolorallocate($im, 233, 14, 91);

imagestring($im, 1, 10, 10, "Online tutorial", $text_color);

imagepng($im);

imagedestroy($im);

?>
Output

generate random in php


generate random in php

In this program is used generate random number in PHP.we are using rand() used to generate random number in PHP.


<?php
echo rand() . "\n";
echo rand(10,4);
?>





Upload file using PHP

Upload file using PHP

HTML Coding

In this example .i will show How upload file using PHP.we are two program here.one is HTM and PHP program.

In the HTML file get the file and send to the PHP program using POST method.


<html>
<body>
<form action="upload.php" enctype="multipart/form-data" method="post">
Select the file to upload<input name="upload" type="file" />
</form>
</body>
</html>

PHP Coding


<?php
$uploadddr='upload/';
$uploadfile=$uploaddr.basename($_FILE[''file']['name']);
if(move_uploaded_file($_FILE['file']['tmp_name'].$uploadfile))
{
echo "file is valid";
}
else
{
echo "file uploading failed";
}?>


PHP Program Explaination:

In the PHP program will get the file stored in file called upload.You must create upload folder in your Computer.

get Http vs Https in php

get Http vs Https in php

In this post. I will show you How do know your server protocol that is Http or https using PHP.
Coding



<?php

if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'
    || $_SERVER['SERVER_PORT'] == 443) {

  // HTTPS
echo 'https';
} else {

echo 'http';  // HTTP

}
?>

Output:

Getting image width and height using PHP

Getting image width and height using PHP

In Coding we are getting size of image using function getimagesize. it is get width and height of given object.


Coding


<?php

  list($width, $height, $type, $attr) = getimagesize("C:\wamp\www\Batista.jpg");

  echo "Image width <br/>" . $width."<br/>";
  echo "Image height <br/>" . $height."<br/>";
  echo "Image type <br/>" . $type."<br/>";
  echo "Attribute <br/>" . $attr."<br/>";

?>

Output





Get ip address using php

Get ip address using php

This tutorial i will show you get the IP(Internet Protocol)Address of proxy server.

Coding


<?php
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
     $ip=$_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
     $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
     $ip=$_SERVER['REMOTE_ADDR'];
echo $ip;
}
?>

Program Explaination:

In this coding the REMOTE_ADDR will finding IP address of proxy server.

Output:




How do finding metatag using PHP

How do finding metatag using PHP:
This tutorial i will show  how do find the metatag of website using PHP. They function called get_meta_tags Which is used to get information of meta tag in the website.


Coding


<?php $tags = get_meta_tags("http://www.w3schools.com"); ?>


<h2>Author</h2>

<?php echo $tags['author']; ?> <br/>      // name 

<h2>Keywords</h2>

<?php echo $tags['keywords']; ?>   </br>  // php documentation

<h2>Description </h2>

<?php echo $tags['description']; ?> </br> // a php manual




Program Explain:


In this Program you finding the meta tag in the website.here  get_meta_tags which used get metatag information you can specific any site here.s

Output:

compare two number without using relational operator in c

#include<stdio.h>
#include<conio.h>
int main () {
{
int a,b;
printf ( "enter the two values u like to compare\n");
scanf (" %d %d",&a,&b);

if (!(a ^ b))

// ^ is Xor operator.
Xor operator function below


valuesvlauesOutput
000
011
101
110


printf ("both are equal\n");
else
printf ("both are not equal\n");
}

Output
Enter the value
10
15
Both are not equals

HTML tag



tag nameDefinitionSyntax
<a> An anchor text which it used to create hyperlinks in HTML. <a href='enter the website name'>Name of site</a>
<b>Which is used to blod the text in HTML.<b>Enter the header name</b>
<ul> Un ordered list which is list the item in HTML.list is nothing but collection of data. <ul type='type of character'>
<ol>ordered list which is orderly list the item in HTML.list is nothing but collection of data. <ol type='disc/square/circle'>
<font> Which is used specific the particular in text we can using this tag in HTML. <font>Enter the text</font>
<basefont >only used in IE not worked in Mozila and chrome and other browser.
<table> table tag which used to create the table in HTML. <table>
<tr>Table row which is used create the table row.

Marquee is used to scroll the text.
<br> BR is used providing new line at the end of paragraph.
<title>
Title tag is used give the title to webpage.
<body>Body tag is used to display data in client browser.
<h1> h1 is used to biggest heading 1
<h2>h2 is used to biggest heading 2
<h3>h3 is used to biggest heading 3


<h4>h4 is used to biggest heading 4
<h5>h5 is used to biggest heading 5
<h6>h6 is used to biggest heading 6
<p>The tag is used in paragraph.every end of paragraph we can put this tag.
<pre>The tag is used tp preserve the white space and lines in the text.
<div>This is tag is used to make the division of section in the html.
<i>It is used show text as italic.
<strong>It is used strong emphasized the text.
<strike>This is used the strike the text.
<center>This tag is used the center the text.

registration form in php


Registration form:
This is registration form in which data are entered by the user then it is goes to database for storing data.In this registration form we create four field and send data using form tag.
<html>
<body>
<form name="form1" action="signup2.php" method="post">
Name<input type='text' name='name'>
Email id<input type='text' name='email'>
Pass<input type='password' name='pass'>
Country<input type='text' name='country'>
<input type='submit' name='submit' value='Insert'>
</form>
</body>
</html>

Storing data in database:

In this program we are create database connectivity storing data which entered by user in registration form.In this data are useful processing the query.

<?php
$conn=mysql_connect('localhost','root','');
$db_name='temp';
mysql_select_db($db_name);
$name=$_POST['name'];
$email=$_POST['email'];
$pass=$_POST['pass'];
$country=$_POST['country'];
$insert=mysql_query("insert into tempv(name,email,pass,country)values('$name','$email','$pass','$country')");
?>

send emails using php

Registration form

We are create registration form which is important in data storing when the entered value in field the data are redirect value to corresponds method by using form tag.Now they store data in Mysql database for furthur processing on the data.

<html>
<body>
<div align='left'>
<table border='1'>

<form name='form1' action='post' method='reglog.php'>
//In which the HTML values will be redirected to reglog.php program using POST method is used


<table bgcolor='skyblue' border='1'>
<tr><td width='50'>Name:</td><td width='50'><input type='name' name='name' placeholder='Enter the Name'>
</td></tr>
<tr><td width='50'>Password:</td><td width='50'><input type='password' name='pass' placeholder='Enter the password'>
</td></tr>
<tr><td width='50'>Retype password:</td><td width='50'><input type='password' name='pass' placeholder='Retype Password'>
</td></tr>
<tr><td width='50'>Email id:</td><td width='50'><input type='text' name='email' placeholder='Enter the Email id'>
</td></tr>
<tr><td width='50'></td><td width='70'><input type='submit' value='Submit'>
</td></tr>
<tr>
</form>
</tr>
</table>
</div>
</body>
</html>


Mysql connectivity

Now we are going to create the database for storing data in verification process .using following MYSQL syntax to create database in MYSQL

Common Syntax
Create database
create database database_name;
Use database
use database_name;
create table query
create table tab_name(tab_name varchar(20),tab_name1 varchar(20),tab_name3 varchar(20),tab_name4 varchar(20),));


Sending mail in php:

Now we are create database connectivity for the program

<?php
$tbl_name=name of table;
// Random confirmation code
$confirm_code=md5(uniqid(rand()));
// values sent from form
mysql_select_db($db_name);
$name=$_POST['name'];
$pass=$_POST['pass'];
$repass=$_POST['repass'];
$email=$_POST['email'];
$insert=mysql_query("insert into table_name(name,pass,repass,email)values('$name','$pass','$repass','$email')");
if($result)
{
$to=$email;
$subject="Your confirmation link here";
$header="from: your name ";
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://www.yousiteaddress.com/confirmation.php?passkey=$confirm_code";
$sentmail = mail($to,$subject,$message,$header);
}
else
{
echo "Not found your email in our database";
}
if($sentmail)
{
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}
?>

HTML list

HTML list
List is nothing but the collection of items or elements.There are two type of list are
ordered list,unordered list

UnOrdered List:

UnOrdered List is used for simply using listing the items but if we want the items in the sequence then ordered lists are used.

HTML Unordered List Example
    <html>
    <body>
    <b>Fruit List</b>
    <ul type='disc'>
    <li>Orange</li>
    <li>Apple</li>
    <li>Pine apple</li>
    </ul>
    <b>Sports List</b>
    <ul type='square'>
    <li>Cricket</li>
    <li>Foot Ball</li>
    <li>Hockey</li>
    </ul>
    <b>Country List</b>
    <ul type='circle'>
    <li>India</li>
    <li>Usa</li>
    <li>UK</li>
    </ul>
    </body>
    </html>

Output of Unordered List
  • Orange
  • Apple
  • Pine apple
Sports List
  • Cricket
  • Foot Ball
  • Hockey
Country List
  • India
  • Usa
  • UK
    Ordered List:
                  Ordered List is used for simply using listing the items but the follow some specific.we can use number the text using ol tag.
    Example

    <html>
    <body>
    <b>Fruit List</b>
    <ol type='1'>
    <li>Orange</li>
    <li>Apple</li>
    <li>Pine apple</li>
    </ol>
    <b>Sports List</b>
    <ol type='A'>
    <li>Cricket</li>
    <li>Foot Ball</li>
    <li>Hockey</li>
    </ol>
    <b>Country List</b>
    <ol type='i'>
    <li>India</li>
    <li>Usa</li>
    <li>UK</li>
    </ol>
    </body>
    </html>

    output

    1. Orange
    2. Apple
    3. Pine apple
    Sports List
    1. Cricket
    2. Foot Ball
    3. Hockey
    Country List
    1. India
    2. Usa
    3. UK

    HTML audio

    Audio
    using html script we can play the audio files.The simplest way to play the audio use the hyperlinks.

    Syntax:

    <a href="location of file'>name of the audio</a>


    Syntax


    <html>
    <head>
    <title>
    HTML checkbox
    </title>
    </head>
    <body>
    <form name='form1'>
    <a href="chimes.wav'>Click the audio</a>
    </form>
    </body>
    </html>



    HTML spacing

    Cellspaing
    Cellspacing is allows create distance from each cell can be increased.
    Example

    <html>
    <head>
    <title>
    HTML cellspacing
    </title>
    </head>
    <body>
    <table border="1" cellspacing="20">
    <tr>
    <td>one</td>
    <td>second</td>
    </tr>
    <tr>
    <td>Three</td>
    <td>four</td>
    </tr>
    </table></body>
     </html>


    Output

    one second
    Three four

    HTML cellpadding

    Cellpadding
    Cellpadding is allows to have some space between of each cell and it is borders(or inner edges)
    Example

    <html>
    <head>
    <title>
    HTML cellpadding
    </title>
    </head>
    <body>
    <table border="1" cellpadding="8">
    <tr>
    <td>one</td>
    <td>second</td>
    </tr>
    <tr>
    <td>Three</td>
    <td>four</td>
    </tr>
    </table></body>
     </html>


    Output
    one second
    Three four

    HTML checkbox

    Check Box
    It is simplest component which is used particularly whemn we used to make selection of serveral options.
    Syntx
    <input type='checkbox' name='check' value='value of checkbox'>
    Example

    <html>
    <head>
    <title>
    HTML checkbox
    </title>
    </head>
    <body>
    <form name='form1'>
    <input type='checkbox' name='check' value='apple'>
    <input type='checkbox' name='check' value='orange'>
    </form>
    </body>
    </html>




    Output


    Apple


    HTML textarea

    Text Area
    Text field is a form component which allows us to enter the single line text,what if we want to have multiple line text?Then you must use the text area components.
    Syntx
    &lttextarea cols='20' rows='20' name='myname'>
    Example

    <html>
    <head>
    <title>
    HTML Textarea
    </title>
    </head>
    <body>
    <form name='form1'>
    Enter the text<textarea cols='20' rows='20' name='myname'>
    </textarea>
    </form>
    </body>
    </html>







    <br /> HTML Textarea<br />


    Enter the text


    Output

    Enter the text


    HTML button

    Button
    There are two buttons that can be created in HTML.one is called submit button.and other is reset button.

    parameters of submit button
    • name:
      denotes the name of the submit the button.
    • value:
      It is writing some text on the text on button.
    • align:
      specifies the alignment of the buttons.
    • Example

      <html>
      <head>
      <title>
      HTML Button
      </title>
      </head>
      <body>
      <form name='form1'>
      <div align='left'>
      Enter the  fruit name
      <textarea cols="40" rows="6">
      <input type='submit' name='' value='Submit'>
      <input type='reset' name='check' value='reset'>
      </div>
      </form>
      </body>
      </html>
    Output




    HTML text

    HTML text
    Text is typically required to place one line text.for example if you want to enter name then it is always preferred to have Text field on the form.The text field can be set using
    <input type='text' size='size of text' value="">


    Some other parameters can be
    • name :
      indicates the name of text field
    • Max length:
      That allow us to enter the text of some maximum length.
    • align:
      denotes the alignment of the text field.The alignment can be left,right,bottom and top.
    Example
    <html>
    <head>
    <title>
    HTML Text
    </title>
    </head>
    <body>
    <form name='text'>
    <input type='text' size='20' value="textfield">
    </form>
    </body>
    </html>

    Output



    HTML forms

    HTML forms
    Form is a typical layout on the webpage by which a user can interact with the web page.
    <form> tag is used to has an attribute action which gets executed when user clicks the button on the form.
    syntax
    Example
    <html>
    <head>
    <title>
    HTML forms
    </title>
    </head>
    <body>
    <form name='form1' action='get' method='get.html'>
    Name<input type='text' name='name'>
    </form>
    </body>
    </html>



    Some of parameters:
    • name: it is used to show the name of forms
    • action:
      get: it is used to send to data to client browser.it is shows the value in addressbar.
      post: it is used to send to data to specified HTML page.it is don't shows the value.

    • method:   it is which page we can redirect it.

    Output




    HTML table

    HTML table tags
    The table is a matrix of rows and columns and one area formed due to interaction of a row and a column is called cell
    To create a table on the web page the table beginning tag is <table>and </table>tag it is used to ending the tag.
    <html>
    <head>
    <title>
    HTML Table
    </title>
    </head>
    <body>
    <table border="6">
    <caption align="bottom">
    </caption>
    <tr>
    <td>This is left cell row1</td>
    <td>This is right cell row1</td>
    </tr>
    <tr>
    <td>This is left cell row2</td>
    <td>This is right cell row2</td>
    </tr>
    </table>
    </body>
    </html>



    Output


    This is left cell row1 This is right cell row1
    This is left cell row2 This is right cell row2


    HTML frameset

    HTML frames
    HTML frames allow us to present document in multiple views.Using the multiple view we can keep certain information visible and at the same time other views are scrolled or replaced.
    <frameset cols="150,*">
    This allow us to divide the two columns.(i.e vertical frames).One are occupying the size of 150 pixels and the other occupies the remaining portion of the window.
    <frameset  rows='20%,30%,50%, cols='30%*'>

    Example
    <html>
    <head>
    <title>
    HTML Frame
    </title>
    </head>
    <frameset cols="50%,50%">
    <frame src="htmlalign.html" name="leftvertical">
    <frameset rows="*,170%">
    <frame src="htmlfont.html" name="right">
    <frame src="htmlformatting.html" name="right_bottom">
    </frameset>
    </frameset>
    </html>
    Output


    HTML HyperLinks

    HTML Hyperlinks
                 There is a common practice the specify the the web link in the webpage.The Link acts as a pointer to some web or some resource.Use the hyper links in the webpage allow page to link logically with other page.
              We can use the hyperlinks by using a tag <a>and by specified the URL for href.The be assigned to href the specifies the the target of the link.

    Syntax
    <a href='link url'>name of link</a>
    Example
    <html>
    <head>
    <title>
    HTML Hyperlinks
    </title>
    </head>
    <body>
    <a href='http://cprogramtutorials.blogspot.in'>Online tutorial</a>
    </body>
    </html>
    Output
    Online tutorial



    HTML Alignment

    Text Alignment
    We can align the text at left,right,center using <div> tags.
    syntax
    <div align='left/center/right'>
    Example

    <html>
    <head>
    <title>
    HTML Alignment
    </title>
    </head>
    <body>
    <div align='left'>This is left align</div>

    <div align='right'>This is right align</div>

    <div align='center'>This is center align</div>
    </body>
    </html>

    Output

    This is left align

    This is right align

    This is center align

    HTML font

    Font in html
    We can set the font,size and color of the text in the webpage.The tag <basefont>is the set the font.
    Syntax
    <basefont face=font_name>
    Example
    <html>
    <head>
    <title>
    Html font
    </title>
    </head>
    <body>
    <basefont face='arial' size='20'>
    Today is greeny day<br/>
    Today is graceful day</br>
    </font>
    </body>
    </html>

    Output

    Today is greeny day
    Today is graceful day





    HTML formatting

    Formatting the text
    Following are some commonly used tags to format the text
    TagMeaning
    <p>This tag is should be put at the every paragraph
    <br>This is tag causes the single line breaks.Generally it is kept at
    the end of every line
    <pre>This tag is used to perserve the white spaces and lines the text
    <div>This is tag used to make division the sections in the HTML document
    Example
    <html>
    <head>
    <title>
    The HTML formatting
    </title>
    </head>
    <body>
    <p>
    once upon a time there was king who kept a monkey as a pet.
    The monkey served the king.
    </p>
    <div>
    The woman took the wood and thanked him for his kindness, but when the last stick was burned, the monkey cried out at forest.
    </div>
    <pre>
    Every time the newest monkey takes to the stairs,
     he is attacked.
     Most of the monkeys that are beating him have no idea          why they were not permitted to climb the stairs or why they are participating in the beating of the newest monkey.
    </pre>
    </body>
    </html>



    Output


    once upon a time there was king who kept a monkey as a pet.
    The monkey served the king.

    The woman took the wood and thanked him for his kindness, but when the last stick was burned, the monkey cried out at forest.
    Every time the newest monkey takes to the stairs,
    he is attacked.
    Most of the monkeys that are beating him have no idea          why they were not permitted to climb the stairs or why they are participating in the beating of the newest monkey.
    

    html header

    Displaying Header
    we are using header tags which helps to display the text as some header.The header tag is used by h1,h2,h3,h4,h5,h6
    Example
    <html>
    <head>
    <title>
    HTML header
    </title>
    </head>
    <body>
    <h1>This is first header</h1>
    <h2>This is second header</h2>
    <h3>This is third header</h3>
    <h4>This is forth header</h4>
    <h5>This is fifth header</h5>
    <h6>This is sixth header</h6>
    </body>
    </html>

    Output

    This is first header

    This is second header

    This is third header

    This is forth header

    This is fifth header
    This is sixth header


    HTML Syntax

    HTML syntax
    An HTML document consists of three parts
    • <html>
    • <head>section
    • <body>section
    <html>
    <head>
    <title>
    -------
    </title>
    </head>
    <body>
    --------
    </body>
    </html>

    HTML element

    HTML Elements
    In the character enclosed within is basically as element.The element tree can be shown below



  1. In all HTML document the root element is <html>which has two children head and body .Any text contained does not appear in client area of web browser.
  2. The head element is used for providing certain information to web browser.



  3. The <title>element is used to give title to the web page.
  4. The <body> element contains the information which is to be displayed in the client area of web browser.
  5. HTML Introduction

    HTML stands for Hyper Text Markup Language(HTML).This is basically a scripting language.HTML is a SGML(Standard General Markup Language)
    HTML Introduction

  6. As we know HTML stands Hyper Text Markup Language.Hyper text is simply a piece of text that works as a link


  7. Markup Language is language of writing layout information within document. 


  8. <html>
    <title>My HTML</title>
    </html>

    Output

    argument passed by reference

    By default arguments are passed by value(so that it will changed inside function only not outside the function).So we are going the value then send value by reference,prepend by (&) to the argument name in the function definition.
    Syntax
    function fun_name(&$varname)
    Example

    <?php
    function my(&$num)
    {
    $num='welcome';
    }
    $str="welcome";
    my($str);
    echo $str;

    ?>


    Output


    passing arguments

    Information may be passed to function via the argument list.which is a comma-delimited list of expression
    Example

    <?php
    function my($num)
    {
    echo "$num";
    }
    my("india");
    ?>


    Output

    conditional operator

    The ? operator is equivalent to an if statement.it os called a terary operator because it takes three parameters an expression :an expression that is evaluated to be TRUE and FALSE an expression that is evaluates if it tree and expression evaluated if the first is FALSE

    Syntax
    (expr1)?(expr2):(expr3);
    Example

    ?php
    $n=6;
    $b=7;
    $val=($num 1>b)?$n:$b;
    echo "The greatest value is $val";

    ?
    output

    require_once in php

    The require_once()statement include and evaluates the specified file during of execution of the script.This is a behavior similar to the require() function with the only difference being that it code from a file has already been included.It will not be included again.

    Syntax
    include "function name";
    Example
    vars.php


    <?php
    $color='red';
    $fruit='apple';
    echo $fruit."color is".$color"
    ?>
    test.php

    <?php
    echo "a $color $fruit"
    // include 'vars.php
    require_once'vars.php'
    echo "a $color $fruit"
    ?>
    Output:



    require in php

    The require() function is identical to include() except that is handle error differently.
    The the function include() generates a warning(but the script continue execution) while the require() function generates a fatal error (and script stop)
    Syntax
    include "function name";
    Example
    vars.php


    <?php
    $color='red';
    $fruit='apple';
    echo $fruit."color is".$color"
    ?>
    test.php

    <?php
    echo "a $color $fruit"
    // include 'vars.php
    require'vars.php'
    echo "a $color $fruit"
    ?>
    Output:



    include_once in php

    The include_once()statement include and evaluates the specified file during of execution of the script.This is a behavior similar to the include() function with the only difference being that it code from a file has already been included.It will not be included again.

    Syntax
    include "function name";
    Example
    vars.php


    <?php
    $color='red';
    $fruit='apple';
    echo $fruit."color is".$color"
    ?>
    test.php

    <?php
    echo "a $color $fruit"
    // include 'vars.php
    include_once'vars.php'
    echo "a $color $fruit"
    ?>
    Output:

    include in php

    The include() function takes all the text in a specified file and copies it into file that used the include function
    Syntax
    include "function name";
    Example
    vars.php


    <?php
    $color='red';
    $fruit='apple';
    echo $fruit."color is".$color"
    ?>
    test.php

    <?php
    echo "a $color $fruit"
    // include 'vars.php
    include 'vars.php'
    echo "a $color $fruit"
    ?>
    Output:



    echo and print

    The echo() and print() function are used to output the given argument.it can output all types single and multiple outputs can be made with these command
    Syntax
    int print(string $arg)
    void echo (string $arg1[,string $ ,,])
    Similarities
    They both language constructs (not function)so they can be used without parentheses
    Example


    <?php
    echo "welcome to india":
    print "welcome to india";

    ?>

    Output:

    PHP directory

    PHP file

    PHP File
    PHP has powerful file handling function to manage file in a server.Some of these function require some special setting in php.ini and some available by default.

    Function in File
    write file
    read file
    open the file

    localtime in php

    The localtime() function returns the array that contains the time components of unix time system
    Syntax
    localtime(timestamp,is_associative)
    Example


    <?php
    print_r(localtime());
    echo("

    ");
    print_r(localtime(time(),true));
    ?>
    output


    idate in php

    idate() function formats a local time or date as integer
    Syntax
    idate(format,timestamp)
    Example


    <?php
    echo(idate("Y")):
    ?>
    Output:


    time in php

    time() function returns the current time as unix tiemstamp (the number of seconds since jan 1 1970 00:00:00 GMT)
    Syntax
    time(void)
    Example


    <?php
    $curr=time();
    print_r("$curr");
    ?>
    Output:

    getdate() in php

    getdate() function returns an array that contains date and time information for unix system
    the returning array contain ten elements with relevant information needed when formatting a date

    • [seconds]-seconds
    • [minutes]-minutes
    • [hours]-hours
    • [mday]-day of month
    • [wday]-day of week
    • [year]-year
    • [yday]-day of year
    • [weekday]-name of the weekday
    • [month]-name of the month
    Syntax
    getdate(timestamp)
    Program


    <?php
    $today=getdate(date("U"));
    print("$today[weekday],today[month]],today[mday],today[year]");
    ?>

    Output


    date and time in php

    date and time function allow you to extract and format the date and time on the server.
    Note
    These function depend on the locale settings of the server
    date()

    date() function formats a local time/date
    The following describes the format arguments
    • a:am or pm
    • A:AM or PM
    • d:Numeric day of the month
    • D:Short day abbreviation
    • F:Full month name
    • g:12-hour time without leading zero
    • G:24-hour time without leading zero
    • h:12-hour time with leading zero
    • H:24-hour time without leading zero
    • i:mintues with leading zero
    • L:Boolean indicating a leap year
    • m:Numeric month with leading zero
    • M:Short month abbreviation
    • n:Numeric month without leading zero
    • O:GMT offset in[+]HHMM format
    • s:seconds
    • S.Suffix to numerical date
    • T:Time zone name
    • U:Unix seconds
    • w:Numeric day of the week
    • y:two digit year
    • Y:Four digit year