What is javascript

Introduction:-javascript is an object oriented programming language used by several websites for scripting  webpages. It is an interpreated programming language which enables dynamic interactivity on websites.

Features of javascript:-

1.all the websites support javascript, they provide built in execution environment.

2. it is a structured programming, it follows c programming language syntax and structure.

3. it is a case sensitive programming language.

4. it is a light weight interpreated language.

5. it is supportable in several operating system including macOS, windows etc.

Places to put JavaScript code:-

  1. Between head tag.
  2. Between body tag.
  3.  In external file(.js file)

javascriptComment:- it is a meaningful way to deliver messange,warning,suggestion or information about the code .

there are 2 types of javascript comment:

  1. Single-line comment
  2. Multi-line comment
  3. Single line comment:-  single line comment is used by adding forward slashes(//) before the line.
  4. Multi line comment:- it is represented by forward slash with asterisk then asterisk with forward slash.

Example:-/* code is here*/

JavaScript variable:- variable in javascript is a name of storage location.

There are 2 types of variables:-

  1. Local variable
  2. Global variable

Local variable:- Javascript local variable is declared inside the lock or function. It is accessible within the function or block.

Global variable:- It is declared outside the function and accessible from any function.

Javascript datatypes:-Datatypes hold different types of values.

There are two types of data types:-

  1. Primitive data type(string,number,Boolean undefined,null)
  2. Non-primitive data type(object,Array,RegExp)

Javascript operators:-

. javascript operators are the symbol which are used to perform operations on operands

1.Arithmetic Operators

2. Comparison (relational) operators

3. Bitwise Operators

4. logical Operatiors

5. Assignment Operators

6. Special Operators

Javascript if-else:

If else statement is used to execute wheather condition is true or false.

There are three forms of if ststements in javascript:-

  1. If statement
  2. If else statement
  3. If else if statement
Tagged :

Super Global Variables in PHP

  • What is Super Global Variable?

Super global variable is a variable which can be used in two different files for manipulation.

For example we have a variable “a” in File1.php and we need to print, edit or any manipulation needed to be done in the variable in File2.php then we have to use Super Global Variable as a variable in File1.php.

  • Types of Super Global Variable in PHP:-

– $_GET

– $_POST

– $_REQUEST

– $_COOKIE

– $_SESSION

– $_FILES

  • To see the use of variable $_GET and $_POST follow the link given below:

/http://www.scmgalaxy.com/tutorials/_get-and-_post-variable-in-php/

  • Use of variable $_REQUEST

 $_REQUEST can catch the data which is sent using both POST GET methods whereas $_GET and $_POST can catch the data which is sent by get and post.

  • Use of variable $_SERVER

When we use $_SERVER we can extract extra data from the client when the form is filled. Extra data in a sense we can extract:

– HTTP Connection

– Server Information

– Host Information

– URL Information

We can see it with the example given below:

Now when we insert the data in the form.html we will see the following information:

  • Use of $_COOKIE variable:

Cookies are small file that the server embeds on the user’s computer each time the same computer requests a page with a browser it will send the cookie too. With PHP, we can both create and retrieve cookie values.

To create a cookie we need to run the following command:

setcookie()

Syntax:

setcookie(name, value, expire, path, domain, secure, httponly);

In the syntax only the name parameter is mandatory rest other parameters are optional.

Example for creating a cookie:

  • Use of $_SESSION variable

For session variable refer the link given below:

How Session works in PHP

Tagged : / / / /