Javascript Functions


Javascript Functions


Learn How To Create Functions in Javascript.
Javascript Function are of Four Types :-

a. No Argument With No Return Type
b.No Argument With Return Type
c.Argument With No Return type
d.Argument With return Type

Now Lets Start.

Example of function :-

function hello() // create function hello
{
//body and scope of function
}


1. No Argument With No Return Type

Code : -

<html>
<head>
<script>

function hello() // Create a function hello with no argument
{
console.log( “Calling Function hello”);
}

hello(); // Calling Function hello
// Output : Calling Function Hello in Your Console By Clicking On F12
</script>
</head>
<body>
<h2>Javascript Functions Tutorial</h2>
</body>
</html>

2. No Argument With Return Type

Code : -

<html>
<head>
<script>

function hello() // Create a function hello with no argument
{
var str=“Calling Function hello”;
return str; // Return Value
}

var srt1=hello(); // Calling Function hello Here We Use Echo To Print
console.log(str1); //Because it Only Return Value Not Print it
// Output : Calling Function Hello
</script>
</head>
<body>
<h2>Javascript Functions Tutorial</h2>
</body>
</html>

3. Argument With No Return Type

Code : -

<html>
<head>
<script>

function hello(a) // Create a function hello with argument
{
console.log(a); // Print Value
}

var ab=”hello test”;

hello(ab); // Calling Function hello With Parameter ab
// Output : hello test
</script>
</head>
<body>
<h2>Javascript Functions Tutorial</h2>
</body>
</html>

4. Argument With Return Type

Code : -

<html>
<head>
<script>

function hello(a) // Create a function hello with argument
{
var a=a.toLocaleUpperCase(a);
return a; // Return Value
}

var ab=”hello test”;

var out=hello(ab); // Calling Function hello With Parameter ab
console.log(out); // Output : Hello test Here first letter of word is capital
</script>
</head>
<body>
<h2>Javascript Functions Tutorial</h2>
</body>
</html>
Thank You
0

PHP $_REQUEST, $_GET and $_POST Variables


PHP $_REQUEST, $_GET and $_POST Variables
php get post request variables

This Are the PHP GLOBAL Variable in PHP Which helps to get value from one page to other or in Html Form Submitting or Passing Value with URL Then We Use This Variables to Get the values.

$_GET

$_GET - > This variable is used when we submitting our form by using method is equal to get or opening any page with passing value in url like ( hello.php?id=1 ). Then we get the Value by using $_GET[‘id’] . When We used get method in form Submitting then we see our key and Value pair in url.

What is key and value?

Example : hello.php?id=1

Here id is key and 1 is value.

$_POST

$_POST - > This variable is used when we submitting our form by using method is equal to post . When We used post method in form Submitting then we cannot see our key and Value pair in url.

Example : -

code 1. hello.html

<html>
<head>
<title>Post Example in PHP </title>
</head>
<body>
<form action=”post.phpmethod=”post”>
Name : <input type=”textname=”name”>
<input type=”submitvalue=”submit”>
</form>
</body>
</html>
Code 2. post.php
<?php
echo $_POST[‘name’];
?>

$_REQUEST

$_REQUEST - > This variable is works both with get and post when we submitting our form by using method is equal to get or post Or opening any page with passing value in url like ( hello.php?id=1 ). Then we get the Value by using $_REQUEST[‘id’] . REQUEST is Really Great Variable Works with Both Get and Post We dont care about method When we using REQUEST.

Example : -

code 1. hello2.html

<html>
<head>
<title>Request Example in PHP </title>
</head>
<body>
<form action=”request.phpmethod=”post”>
Name : <input type=”textname=”name”>
<input type=”submitvalue=”submit”>
</form>
</body>
</html>
Code 2. request.php
<?php
echo $_REQUEST[‘name’];
?>

Thank You
0

PHP Functions

 
PHP Functions

php function


Learn How To Create Functions in PHP.
Function are of Four Types :-

a. No Argument With No Return Type
b.No Argument With Return Type
c.Argument With No Return type
d.Argument With return Type

Now Lets Start.

Example of function :-

function hello() // create function hello
{
//body and scope of function
}


1. No Argument With No Return Type

Code : -

<?php

function hello() // Create a function hello with no argument
{
echo “Calling Function hello”;
}

hello(); // Calling Function hello
// Output : Calling Function Hello
?>

2. No Argument With Return Type

Code : -

<?php

function hello() // Create a function hello with no argument
{
$str=“Calling Function hello”;
return $str; // Return Value
}

echo hello(); // Calling Function hello Here We Use Echo To Print
//Because it Only Return Value Not Print it
// Output : Calling Function Hello
?>

3. Argument With No Return Type

Code : -

<?php


function hello($a) // Create a function hello with argument
{
echo $a; // Print Value
}

$ab=”hello test”;

hello($ab); // Calling Function hello With Parameter $ab
// Output : hello test
?>

4. Argument With Return Type

Code : -

<?php


function hello($a) // Create a function hello with argument
{
$a=ucfirst($a);
return $a; // Return Value
}

$ab=”hello test”;

$out=hello($ab); // Calling Function hello With Parameter $ab
echo $out; // Output : Hello test Here first letter of word is capitalize
?>
Thank You
3

PHP and Javascript (JS) if,if else,if elseif...else


PHP and Javascript (JS) if,if else,if elseif...else


What is If Statement in Programing ?
In programing we need to check the condition if condition is true then we perform task 1 else we perform task 2
then we can check this conditions by if statement


Simple Voting Example
If Our Age is Greater then 18 we are eligible for vote else we are not eligible.


if (we are greater than 18)
{
eligible
}
else
{
we are not eligible
}


Condition Statements Are Of Four Types


1. if statement - Execute Condition if true
2. if...else statement - Execute Task 1 if condition true otherwise Perform Task 2
3. if...elseif....else statement - Executes Task More Than One Condition if Condition Satisfy Perform The Task Else Perform Default else Task
4. switch statement - Perform Task If Condition Satify in any Case and Perform The Result.


if syntax


if (condition) {
if condition true
}


Example 1
if Condition in php


<?php
$a=1;
if($a%2==0) //checking the condition
{
echo "even no"; //print even no if condition is true but here we will get nothing because 1 is an odd number
}
?>


if Condition in Javascript (Js)


<html>
<head>
</head>
<body>
<h1>If Statement in Javascript</h1>
</body>
<script>
var a=1;
if(a%2==0) //checking the condition
{
console.log("even no"); //we get the output nothing in our console by clicking on F12
}
</script>
</html>
Flow Chart Of if Statement


if else syntax


if (condition) {
if condition true
}
else
{
else condition true
}


Example 1
if else Condition in php


<?php
$a=1;
if($a%2==0) //checking the condition
{
echo "even no";  //print even no if condition is true but here we will get nothing because 1 is an odd number
}
else{
echo "odd no";  //print odd no. we know that 1 is a odd number
}
?>


if else Condition in Javascript (Js)


<html>
<head>
</head>
<body>
<h1>If else Statement in Javascript</h1>
</body>
<script>
var a=1;
if(a%2==0) //checking the condition
{
console.log("even no"); //we get the output nothing in our console by clicking on F12
}
else
{
console.log('odd no'); //we get output odd no
}
</script>
</html>
Flow Chart Of if else Statement


The if...elseif....else


if (condition) {
if condition true
}
elseif
{
else condition second
}
else
{
else third condition
}


Example 1
if elseif.. if Condition in php


<?php
$a=1;
if($a<0) //checking the condition
{
echo "a is smaller then zero"; 
}
else if($a>1) //second condition
{
echo "a is smaller then 1";
}
else //else last condition
{
echo “a is equal to 1”;
}
?>


if else Condition in Javascript (Js)


<html>
<head>
</head>
<body>
<h1>If elseif... else Statement in Javascript</h1>
</body>
<script>
var a=1;
if(a<0) //checking the condition
{
console.log( "a is smaller then zero"); 
}
else if(a>1) //second condition
{
console.log("a is smaller then 1");
}
else //else last condition
{
console.log( “a is equal to 1”);
}
</script>
</html>
Flow Chart Of if elseif....else Statement

0

Two Column and Three Column Layout Using HTML and CSS


Two Column and Three Column Layout Using HTML and CSS

Since Many User Want To Create A Two Column and Three Column Layout in Our Site So Here is the Example With Code To Create it Easily.

1.Two Column Layout Right Sidebar

Code :


<!DOCTYPE html>
<html>
<head>
<title>Columns Layout 1</title>
<style type="text/css">
.column1
{
width: 70%;
float:left;
background: whitesmoke;
}
.column2
{
width: 30%;
float: right;
background: orange;
}

footer
{
clear: both;
background: grey;
padding: 20px;
}
header
{
background: grey;
padding: 20px;
}
body{
width: 100%;
}
header section
{
padding: 20px;
}
footer section
{
padding: 20px;
}
.column1 section
{
padding: 20px;
}
.column2 section
{
padding: 20px;
}
</style>
</head>
<body>
<header>
<section>This is demo Of Two Column Layout</section>
</header>
<div class="column1">
<section><p>This is left Content Area</p><br><p>
<strong>Where does it come from?</strong>

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
</p></section>

</div>
<div class="column2">
<section><p>This is Right Sidebar Area</p><br><p>
<strong>Why do we use it?</strong>

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p></section>
</div>
<footer>
<section>This is Footer</section>
</footer>

</body>
</html>

Screenshot :


2.Two Column Layout Left Sidebar

Code :

<!DOCTYPE html>
<html>
<head>
<title>Columns Layout 2</title>
<style type="text/css">
.column1
{
width: 70%;
float:right;
background: whitesmoke;
}
.column2
{
width: 30%;
float: left;
background: orange;
}

footer
{
clear: both;
background: grey;
padding: 20px;
}
header
{
background: grey;
padding: 20px;
}
body{
width: 100%;
}
header section
{
padding: 20px;
}
footer section
{
padding: 20px;
}
.column1 section
{
padding: 20px;
}
.column2 section
{
padding: 20px;
}
</style>
</head>
<body>
<header>
<section>This is demo Of Two Column Layout</section>
</header>
<div class="column1">
<section><p>This is left sidebar Area</p><br><p>
<strong>Where does it come from?</strong>

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
</p></section>

</div>
<div class="column2">
<section><p>This is Right content Area</p><br><p>
<strong>Why do we use it?</strong>

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p></section>
</div>
<footer>
<section>This is Footer</section>
</footer>

</body>
</html>


Screenshot :


3.Three Column Layout

Code :

<!DOCTYPE html>
<html>
<head>
<title>Columns Layout 3</title>
<style type="text/css">
.column1
{
width: 20%;
float:left;
background: orange;
}
.column2
{
width: 60%;
float: left;
background: yellow;
}
.column3
{
width: 20%;
float: left;
background: orange;
}
.column1,.column2,.column3
{
min-height: 600px;
}


footer
{
clear: both;
background: grey;
padding: 20px;
}
header
{
background: grey;
padding: 20px;
}
body{
width: 100%;
height: 100%;
}
header section
{
padding: 20px;
}
footer section
{
padding: 20px;
}
.column1 section
{
padding: 20px;
}
.column2 section
{
padding: 20px;
}
.column3 section
{
padding: 20px;
}
article,article div
{
height: 100%;
}
</style>
</head>
<body>
<header>
<section>This is demo Of Three Column Layout</section>
</header>
<article>
<div class="column1">
<section><p>This is left sidebar Area</p><br><p>
<strong>Where does it come from?</strong>

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature,
</p></section>

</div>
<div class="column2">
<section><p>This is content Area</p><br><p>
<strong>Why do we use it?</strong>

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.
</p></section>
</div>
<div class="column3">
<section><p>This is Right Sidebar Area</p><br><p>
<strong>Why do we use it?</strong>

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.
</p></section>
</div>
</article>
<footer>
<section>This is Footer</section>
</footer>

</body>
</html>

Screenshot :
Thank You

1