Saturday, December 26, 2020

Javascript tutorial part- 2 variable and datatypes.

 



Variable name is name of memory location in which we are going to store data.

Three keywords  are used for declare variable.

1.     Var

2.     Let

3.     Const

Var and let are used for declaring variable i.e that data may vary in the current program and const is the keyword used to declare constants. Constance means once defined we cannot alter its value.

let name=”Muthu karthikeyan”;

let isMarried=true;

let age=46;

name is assigned a string so name is a string.

isMarried is assigned true value which is a Boolean

age is assigned a number datatype. So it is a number data type.

console.log(“name”);

console.log(name)

 

output:

name

Muthu karthikeyan

The data which is within double quotes is printed as itself.

Without quotes is treated as variable and prints its value.

There is an another data type which it called is undefined.

For example.

let  fullName

console.log(fullName);

output:

undefined.

The output is undefined because we still didn’t assign any value to variable name called as fullName.

const a=10;

a=25;

output:

error. 

output is error because we are altering a constant. a is a constant because it declared with keyword const.

-will continue.

S.MUTHU KARTHIKEYAN

91 96293 29142

 

 

 

Thursday, December 24, 2020

Javascript tutorial-part 1.

 



 

Javascript is used as client side scripting language.it adds interactive features  to a web page. It is used for validate purpose.

There are two types of validation :

1.     client side validation.

2.     Server side validation

Client side is done at browser. For to limit the user age as 18 we can done at browser. But for example to check no of books available you have check database such this need server side validation.

To run java script different browsers use different engines. For example chrome use v8 and Mozilla use spider monkey engines

Now a day visual studio code is a popular editor for javascript.

The notes are below are taken from Wikipedia

A JavaScript engine is a computer program that executes JavaScript (JS) code. The first JavaScript engines were mere interpreters, but all relevant modern engines use just-in-time compilation for improved performance.

JavaScript engines are typically developed by web browser vendors, and every major browser has one. In a browser, the JavaScript engine runs in concert with the rendering engine via the Document Object Model.

The use of JavaScript engines is not limited to browsers. For example, the Chrome V8 engine is a core component of the popular Node.js and Deno runtime systems.

Since ECMAScriptt (ES) is the standardized specification of JavaScript, ECMAScript engine is another name for these engines.

Index.html

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

    <script src="./script.js"></script>

</head>

<body>

    <h1>welcome</h1>

    

</body>

</html>

 

Script .js

console.log("welcome to javascript code by karthikeyan and mukesh");

 

 

script is a keyword used to denote java script code. In index.html we mention that source file of script is script.js.

in the above program script,js and index.html are residing at same location.

Now a day Java script is used for server side validation also. We have to install node.js for that purpose.

To run the above program copy path of index.html  in vs code editor.in browsers address bar simply paste it .


 

To see the result of console.log statement in browser press f12 short cut key.

Click console tab and see the results.


We can use node command to run the javascript program directly with out embedding with html program.

To get into terminal in vs code editior

Short cut key is ctrl+~  

The ~ symbol is below esc key at keyboard.

To run script.js  file just type the following line at terminal

Node script.js



-will continue

By Muthukarthikeyan

Contact :919629329142.

 

Saturday, December 5, 2020

How Php application works?

 



This article is for xampp package.

This package contains:

Apache web server.

MySql

Php processor

Php Myadmin.


 

Apache web server is used by great majority  of hosts for web development.

Web server checks the file whether the extension is php and passes php code to php processor.

Php processor checks whether it has any sql statements. It passes query statement to mysql database server. Now php processor executes sql statements and sends back the result to php processor.

Now php processor  interprets the code and send the results to Apache web server.

The server gathers the result of php code along with html, css and/or  javascript code to browser.

Now browser executes the html, css and /or java script code.

MySql and MariaDB are not just databases. They are also called as Database management System.

These packages contain the tools for create, maintain and secure databases.

The php processor interprets the code and if the code has any Syntax error it throws exception.

PhpMyAdmin is a GUI based administration tools for create and maintain database and its table.

This is the basic procedure describes how php works.

Thank you

Muthukarthikeyan, Madurai, Tamilnad , India.

contact:91 9629329142

Email:muthu.vaelai@gmail.com.

 

 

 

Saturday, November 28, 2020

If else statement in php.

 



In  if else structure we will examine a Boolean expression whether it is true or false.

If it is true the statements inside if block will be executed. If it is false the statements inside the else part is executed.

Sample1.php

<?php

$condition=true;

if($condition)

{

    echo 'this is true part'.'<br>';

    echo 'the condition is true'.'<br>';

    

}else{

    echo 'this is false part'.'<br>';

    echo 'the condition is part'.'<br>';

}

?>

 

 

Output:

this is true part
the condition is true

checking a variable is null or not null in php.

<?php

$name="Muthu karthikeyan";

if(!is_null($name))

{

    echo "name is defined <br>";

    echo "your name is $name <br>";

 

}

else{

    echo "name is not defined it is null";

}

?>

 

Output:

name is defined
your name is Muthu karthikeyan.

 

Checking using  isset function.

<?php

$name="Muthu karthikeyan";

if(isset($name))

{

    echo "name is defined <br>";

    echo "your name is $name <br>";

 

}

else{

    echo "name is not defined it is null";

}

?>

 

Output:

name is defined
your name is Muthu karthikeyan

checking using empty property.

<?php

$name="Muthu karthikeyan";

if(!empty($name))

{

    echo "name is defined <br>";

    echo "your name is $name <br>";

 

}

else{

    echo "name is not defined it is null";

}

?>

Output:

name is defined
your name is Muthu karthikeyan.

If condition using number value.

Sample3.php.

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

<body>

    <form action="vote.php">

    <P>  please Enter your age:

    <input type="text" name="txtAge" ></p>

    <P> <input type="submit" name="submit" value="submit">

    </p>

    

    </form>

</body>

</html>

Vote.php.

<?php

$age=$_REQUEST["txtAge"];

if ($age>=18){

 echo "your are eligible for vote";

}

 else{

 echo "not eligible for vote";

}

?>

 

 

Output:

 

 

 

 

Thank you

Muthu karthikeyan.

Contact:91 9629329142

Email:muthu.vaelai@gmail.com.

Madurai, Tamilnad, India.