HTML
1.what is html? what does it stand for? Use of html.
2.what is the full form of html
3.what does <a> tag actually do?
4.how to change color of a text in html?
5.what is non breaking space in html?
6.how to make a table in html?
7.what is iframe in html?
8.what is method, what is action in a form?
9.what are semantic elements in html?
10.How to make a numbered list, how to make bulleted list?
11. What is attribute in an html tag?
12.how to make a form in html?
13.how to have a submit button in a form?
CSS
- What is css? What does it stand for?
- How to use css in html?
- How to use a separate file for css?
- How to change background color?
- What is the difference between padding and margin?
- How to give border to a component?
- How to make a box using css and html?
- How to divide a page using css?
- How to align/arrange components using css?
- What are display properties in css?
- Where and how to use display property in css?
- What is flex-box in css?
- How to align components in flex box?
- What is css grid? How to use css grid?
- What is grid-column-start and grid-column-end in css grid?
- What are position properties in css?
- What is the difference between absolute position and relative position?
- How to have hover effect on a button?
Javascript
- What is javascript?
- How to use javascript in an html file
- How to use javascript from a separate file?
- What are variables in javascript?
- What are loops in javascript?
- What does dynamically typed language means?
- What are the conditional statements in javascript?
- How to the change color of an html component using javascript?
- How to change text from an input using javascript?
- How to get value from an input using javascript?
- How to create rows in a table using javascript?
- How to display output in html using javascript?
- What is the difference between ‘==’ and ‘===’?
- How to assign a value to a variable in javascript?
- Different data types in javascript?
- How to convert a string into an integer?
- How to convert an integer into a string?
- What is a switch statement in javascript?
- How to reverse an array using javascript?
- How to count elements in an array?
- What is object oriented programming?
- What are classes? What are objects in javascirpt?
- What does console.log method do?
- What is an alert?
- What are different types of arrays?
- How to get elements from arrays?
- How to insert elements in an array?
- How to change a value of a variable in an object?
- How to get a variable from an object?
- Types of inheritance in javascript?
- What are prototypes in javascript? How is multiple inheritance achieved?
- What is es6?
- What is v8 engine?
- What is interpreted language?
Php
- What is php? What is the full-form of php?
- What does it mean by server side language?
- What are the things that php can do?
- How to get data from a form submitted by post method?
- How to get data from a form submitted by get method?
- How to know if the form has been submitted?
- What is isset method?
- What is empty method?
- How to connect to database?
- How to insert data in a table?
- How to get data from a table?
- How to delete a row from a table?
- How to update a row from a table?
- How to get a count of a similar string or a value from a table?
- What is join?
- How to compare a value to a column?
- What is $_required in php?
- What are superglobals in php?
- What is a constant? How to define constant in php?
- How to navigate to a different page using php?
- What are the types of variables in php?
- What are string methods in php?
- What are array methods in php?
- What is the difference between include and require?
Answers
HTML
1.what is html? what does it stand for? Use of html.
HTML stands for hypertext markup language, it is used to structure web documents by using various tags and attributes. The html files are saved with ‘.html’ extension.
2.what does html stand for?
HTML stands for hypertext markup language
3.what does <a> tag actually do?
The <a > tag, anchor tag is used to navigate to different documents or web pages. The href attribute is used to specify the url.
4.how to change color of a text in html?
By using color attribute, we can change the color of the text.
Example: <h1 color= red></h1>
5.what is non breaking space in html?
‘&’ in the beginning is used to represent the special characters in html. $nbsp is a special character in html which is used to give space in the document without line-break.
6.how to make a table in html?
By using <table> tag table is defined. For creating rows <tr>is used. For creating header cells in a row <th> tag is used. For creating standard cells <td> tag is used.
Example :
<table >
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
7.what is iframe in html?
Iframe stands for inline-frame. It is used to embed external web pages or documents in the web page. Src attribute is used to specify the url.
8.what is method, what is action in a form?
The method attribute tells the browser how to send data from a form to the server.
There are two methods for sending the form data. POST and GET.
POST method is more secure as it sends the data without displaying it in the url.
GET method is less secure as it displays the submitted data in the url.
GET method is mostly used for queries to the server, when the user wants to get the data. POST method is used when the user wants to send the data.
The attribute action specifies the url where the data should be sent after the form submission.
9.what are semantic elements in html?
Semantic elements gives meaning to the html code, instead of just representation. I.e <p>
Tag tells the browser that the text inside is a paragraph. It describes the meaning to both browser and the developer.
10.How to make a numbered list, how to make bulleted list?
The <ol> tag is used inside of <li> tag to make an ordered list.
The type attribute defines how the list should be numbered. I.e type = ‘1’ would make the list numbered as 1,2,3. Type = ‘A’ would make the list numbered alphabetically.
The <ul> tag is used inside of <li>tag to make an unordered list. This list will be bulleted list.
11. What is attribute in an html tag?
The attributes are used to define the characteristics of html tags and are placed inside the opening tag of elements.
I.e <input name=”name” id=”name”> here name and id are attributes.
12.how to make a form in html?
The <form> tag defines the form in a page. The form has attributes called POST and GET.
The form gets submitted when the user clicks on a button which has type= submit attribute or input which has type=’submit’ attribute. By using the method submit() the form can be submitted by using javascript as well.
The method attribute tells the browser how to send data from a form to the server.
There are two methods for sending the form data. POST and GET.
POST method is more secure as it sends the data without displaying it in the url.
GET method is less secure as it displays the submitted data in the url.
GET method is mostly used for queries to the server, when the user wants to get the data. POST method is used when the user wants to send the data.
The attribute action specifies the url where the data should be sent after the form submission.
13.how to have a submit button in a form?
In button tag we have to use type = ‘submit’ attribute to have a button which can submit the form.
CSS
- What is css? What does it stand for?
CSS stands for cascading style sheets, it is used to style and format web pages.
It could be defined in inline styles or a style tag. It can also be included from another page.
2.How to use css in html?
Ways to embed css are:
Internal css: style tag is used in head tag in which the css is included.
Inline css: the style attribute is used in an element to style that particular element.
External css: external css is using css from external file. external style is defined with link tag in head tag with attributes rel=”stylesheet”
Type = “text/css” and href=”filename.cssl”
I.e
<link rel=”stylesheet” type=”text/css” href=”style.css”>
3.How to use a separate file for css?
External css: external css is using css from external file. external style is defined with link tag in head tag with attributes rel=”stylesheet”
Type = “text/css” and href=”filename.cssl”
I.e
<link rel=”stylesheet” type=”text/css” href=”style.css”>
4.How to change background color?
The background color can be changed by using the property background-color,
I.e <div style=”background-color: green”></div>
5.What is the difference between padding and margin?
Margin is on the outside of block elements while padding is on the inside.
Use margin to separate the block from things outside it
Use padding to move the contents away from the edges of the block.
6.how to give border to a component?
To give border to a particular component there is a property called border. in which you have to specify border width, style and color.
I.e <div style = ‘1px solid black’></div>
7.How to make a box using css
By giving width and height to a div element, we can create a box. we can also use border property to give border to the box.
example:
<div style = ‘width = “100px; height=”100px; border: 1px solid black;”’></div>
8.how to divide a page in sections
By giving float properties to the sections or divs we can divide the page in sections.
Example:
<div id=”section1”></div>
<div id=”section2”></div>
<div id=”section3”></div>
<style>
#section1{
float: left;
Width: 20%;
}
#section2{
float: left;
Width: 80%;
}
#section3{
clear: both;
Width: 100%;
}
</style>
Such can be achieved by using display relative and absolute as well.
9.How to align/arrange components using css?
There are several ways to do this.
You can use flex-box, css-grid, position relative or absolute; top, left, bottom, right properties in conjunction to arrange the components on your page.
Example:
<div style=”position:relative; left:50%;”></div>
<div style=”display:flex; justify-content: center”>
<div id=”box”></div>
</div>
10.What are display properties in css?
The display property of an elements determines the display behaviour of an element.
These are the following display properties
div {
display: inline; /* Default of all elements, unless UA stylesheet overrides */
display: inline-block; /* Characteristics of block, but sits on a line */
display: block; /* UA stylesheet makes things like <div> and <section> block */
display: run-in; /* Not particularly well supported or common */
display: none; /* Hides the element */
}
display: inline is the default value for elements.
11.Where and how to use display property in css?
You should use display property where you want to use display other than display: inline which is default.
This is how display property is used
div {
display: inline; /* Default of all elements, unless UA stylesheet overrides */
display: inline-block; /* Characteristics of block, but sits on a line */
display: block; /* UA stylesheet makes things like <div> and <section> block */
display: run-in; /* Not particularly well supported or common */
display: none; /* Hides the element */
}
13. How to align components in flex-box
Flex box helps designing layouts without float or positioning properties.
Justify-content property is used to align components in the flex-box.
justify-content: flex-start|flex-end|center|space-between|space-around|initial|inherit;
14.What is css grid? How to use css grid?
CSS Grid Layout gives us the ability to divide a page into regions or defining the relationship in terms of size, position, and layer, between parts of a control built from HTML primitives.
15.What is grid-column-start and grid-column-end in css grid?
grid-column-start specifies the grid items start position within grid column.
grid-column-end specifies the grid items end position within grid column.
16.What are position properties in css?
Position specifies the type of positioning method used for the element.
These are following position values.
static
relative
fixed
absolute
sticky
Static: static is the default position value for elements. Static elements are not affected by top, right, left. Bottom positioning values.
relative: An element’s new position relative to its normal position.
Absolute: In position: relative, the element is positioned relative to itself. However, an absolutely positioned element is relative to its parent. This is like relative but they are removed from normal document flow.
Fixed: fixed positioned elements are also removed from the normal document flow.
These are not affected by scrolling and are only relative to the html documents.
Sticky:A sticky element uses both relative and fixed, depending on the scroll position. It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place, the position becomes fixed.
17.What is the difference between absolute position and relative position?
Position absolute | Position relative |
Element is taken completely out of the normal page flow. | Element is in the normal page flow. |
Element is positioned relative to the parent element | Element is positioned relative to itself. |
18.How to have hover effect on a button?
Use hover selector in css to add hover effect.
Example: <button> button </button>
<style>
button:hover{
color: green;
}
</style>
Javacript
1.what is javascript ?
Javascript is client-side scripting or programming language, it is primaraly used on the web. It is commonly embedded in html code. It is an interpreted language so it does not need to compiled. It allows to interact with user and make dynamic pages.
2. How to use javascript in an html file?
Javascript can be used anywhere in an html file. To use javascript in an html page <script> tag is used. To use external javascript file we can add attributes type=”text/javascript” and src=”filepath” to the script tag.
3.how to use javascript from a separate file?
Javascript can be used anywhere in an html file. To use javascript in an html page <script> tag is used. To use external javascript file we can add attributes type=”text/javascript” and src=”filepath” to the script tag.
4.what are variables in javascript?
A variable is an identifier and a storage location for some value.//quora.
Javascript is a dynamically typed language, means the data type gets associated to a variable while being interpreted, on the fly. In javascript the programmer does not have to specify the data type while declaring the variables, it happens dynamically according to the value given to it.
Example:
Var a = “ESENCEWEB”;
// a is now a string variable.
5.What are loops in javascript?
For repeatedly executing a block a code certain times to get a certain result or results loops are used. These loops execute a block of code until a certain condition is being met, or is true.
types of loops in javascript are:
while loop
do-while loop
for loop
for-in loop
while loop: while loop is executed until the specified condition is true.
Example:
while(i<10) //the condition
{
I++; //block of code
console.log(i);
}
do-while loop: in this loop the block of code that is in the loop is executed first. If the given condition is true the loop is executed again. Because of this, the loop is executed at least one time whether or not the condition is true.
Example:
var i = 0;
do{
console.log(i);
i++;
} while(i<10);
for loop: this loop consists of three parts, separated by semicolons. The first part is used for initializing a variable. The second part is used for the condition. The third part is used for updater, which updates the value of the variable with each iteration. The loop is executed until the condition is true.
Example:
for (var i = 0; i < 10; i++) {
console.log(i);
}
for-in loop: A for...in loop only iterates over enumerable, non-Symbol properties. The loop will iterate over all enumerable properties of the object itself.// developer.mozilla.org
Example:
var student = { name:"Bill", age: 25, degree: "Masters" };
for (var item in student) {
console.log(student[item]); // => "Bill", then 25, then "Masters"
}
6.What does dynamically typed language means?
Javascript is a dynamically typed language, means the data type gets associated to a variable while being interpreted, on the fly. In javascript the programmer does not have to specify the data type while declaring the variables, it happens dynamically according to the value given to it.
Example:
Var a = “ESENCEWEB”;
// a is now a string variable.
7.What are the conditional statements in javascript?
Conditional statements determine what part of a code needs to be executed depending upon a condition.
Following are the conditional statements in javascript:
if
else
else if
If : block of code is executed if the condition is true.
else: if the IF condition is not true, the code inside the ELSE block gets executed.
else if: if the first IF condition is not true, other IF conditional statement is run, it can be achieved multiple times.
if (condition1)
{
lines of code to be executed if condition1 is true
}
else if(condition2)
{
lines of code to be executed if condition2 is true
}
else
{
lines of code to be executed if condition1 is false and condition2 is false
}
8.How to change the color of an html component using javascript?
By using the function document.getElementById().style we can access the style of an html component as well as change it.
<p id="p1">Hello World!</p>
<script>
document.getElementById("p1").style.color = "red";
</script>
9.How to change text from an input using javascript?
By using the function document.getElementById().value we can access the value of an html component as well as change it.
<input name=”p1” id=”p1” value=” initial value ”>
<script>
document.getElementById(“p1").value = "My value"; //changes the value
</script>
10.How to get value from an input using javascript?
By using the function document.getElementById().value we can access the value of an html component as well as change it.
<input name=”p1” id=”p1” value=” initial value ”>
<script>
console.log(document.getElementById(“p1").value); // outputs the value
</script>
11.How to create rows in a table using javascript?
The Table insertRow() method is used for creating an empty row element which can be added to a table.
Example:
<table id="Courses"
align="center">
<tr>
<td>Java</td>
<td>Javascript</td>
</tr>
<tr>
<td>python</td>
<td>php</td>
</tr>
</table>
<script>
var table = document.getElementById("Courses");
var row = table.insertRow(0); // Creates an empty row element and adds it to the 1st position of the table:
</script>
12.How to display output in html using javascript?
This can be achieved either by changing the value of an already existing element in html or creating a new html element by using document.createElement() and createTextNode() method.
<script>
var i = 1+2;
var h = document.createElement("H1") ; // creates an element
var t = document.createTextNode(i) ; // creates a text node
h.appendChild(t) ; // appends text node to h1 element
document.body.appendChild(h) ; // appends h1 element to the body
</script>
Or
<p id="p1">Hello World!</p> //html
<script>
var i = ‘esenceweb’;
document.getElementById("p1").innerHTML = “"+i;
</script>
13.What is the difference between ‘==’ and ‘===’?
= is used for assigning values to a variable in JavaScript.
== is used for comparison between two variables irrespective of the datatype of variable.
=== is used for comparision between two variables but this will check strict type, which means it will check datatype and compare two values.
14.How to assign a value to a variable in javascript?
Javascript is a dynamically typed language, means the data type gets associated to a variable while being interpreted, on the fly. In javascript the programmer does not have to specify the data type while declaring the variables, it happens dynamically according to the value given to it.
Example:
Var a = “ESENCEWEB”;
// a is now a string variable.
15.Different data types in javascript?
Following are the datatypes in javascript.
Boolean : A Boolean variable can hold two values, true or false.
Null : Null refers to invalid object or address, it can hold one value which is NULL. it means nothing.
Undefined : A variable that has not been assigned a value has the value undefined.
Number : represents numeric values
BigInt : its a built-in object that provides a way to represent whole numbers larger than
2^53 - 1
String : A String variable contains a set of characters surrounded by double quotes or single quotes, used to represent textual information.
Symbol : Symbols are new primitive type introduced in ES6. Symbols are completely unique identifiers, can be used to store key values of object properties.
16.How to convert a string into an integer?
parseInt() : The parseInt() method converts a string into an integer.
Example:
var c = parseInt(“23”); //value stored is integer 23
17.how to convert an integer into a string?
toString() is used to convert an integer into a string.
example:
var num = 3;
var s= num.toString(); // “3” string is stored.
18.What is a switch statement in javascript?
Switch statement determine what block of code to execute depending upon different cases, conditions.
example:
var fruits = “Apple”;
var text= “”;
switch(fruits) {
case "Banana":
text = "Banana is good!";
break;
case "Orange":
text = "I am not a fan of orange.";
break;
case "Apple":
text = "How you like them apples?";
break;
default:
text = "I have never heard of that fruit...";
}
console.log(text); // text has "How you like them apples?" value.
19.How to reverse an array using javascript?
array.reverse() function reverses the array.
example:
var arr = [0, 1, 2, 3].reverse();
document.write("Reversed array is : " + arr );
20.How to count elements in an array?
Array.length property helps count the number of elements from an array.
example:
var l = [0, 1, 2, 3].length();
document.write(“length of the array is: " + l );
21.What is object oriented programming?
Object Oriented programming is a programming style which is associated with the concepts like class, object, Inheritance, Encapsulation, Abstraction, Polymorphism. It focuses more on objects than functions.
22.What are classes? What are objects in javascirpt?
A JavaScript class is a type of function. Classes are declared with the class keyword. We will use function expression syntax to initialize a function and class expression syntax to initialize a class. // digitaloscean.com
Object is an instance of class which may contain collection of related data of premitive or reference type in key value pairs.
25.what does console.log method do?
Console.log writes a message to the console.
Example:
console.log(‘Esenceweb’);
26.What is an alert?
Alert message displays a message in a alert box whenever it is called.
Example:
alert(‘Esenceweb’);
27.what are different types of arrays?
One dimensional array
Two dimensional array
Three dimensional array
28.how to get elements from an array
We can get elements from an array by using inbuilt javascript method array.values().
Or we can access array elements by using array[index number] to get elements.
Example:
Using array[index number] method
var arr = [1,2,3];
console.log(arr[0]) //printing an element from array
for (var i=0; i<arr.length; i++){ //printing all array elements
console.log( arr[ i ] );
}
Using array.values() method
var arr = [1,2,3];
var iterator = arr.values();
// Here all the elements of the array is being printed.
for (let elements of iterator) {
console.log(elements);
}
29.How to insert elements in an array?
we can add one element at a particular index by giving value to array[‘index’] = ‘value’,
Or we can use array methods like push, concat, unshift, splice to add elements.
var array = [“bananna", "Orange", "Apple", "Mango"];
array[4]=”value”; // adds value to a particular index
array.unshift(“first value”); // adds value in the beginning of the array
array.splice(3, 0, 'a', 'b', 'c'); // adds value in the middle of the array
array.push("strawberry"); // adds value to the end of the array
30.How to change a value of a variable from an object?
We can change the value by using object.property = value or object[property] = value;
Example:
var myObj = {
'name': ‘ganesh’',
'age' : 20
};
myObj.name=value
Or
myObj['name']=value
31.how to get a value from a variable from an object
We can access value of a variable from an object by using object.poperty or object[porperty]
Example:
var myObj = {
'name': ‘ganesh’',
'age' : 20
};
console.log(myObj.name)
Or
console.log(myObj['name'])
34.What is es6?
ECMAScript, or ES6, was published in June 2015. It was subsequently renamed to ECMAScript 2015. Web browser support for the full language is not yet complete, though major portions are supported. Major web browsers support some features of ES6. However, it is possible to use software known as a transpiler to convert ES6 code into ES5, which is better supported on most browsers. //https://www.makeuseof.com/tag/es6-javascript-programmers-need-know/
35.What is v8 engine?
A JavaScript engine is a program or an interpreter which executes JavaScript code. A JavaScript engine can be implemented as a standard interpreter, or just-in-time compiler that compiles JavaScript to bytecode in some form.
This is a list of popular projects that are implementing a JavaScript engine:
V8 — open source, developed by Google, written in C++
Rhino — managed by the Mozilla Foundation, open source, developed entirely in Java
SpiderMonkey — the first JavaScript engine, which back in the days powered Netscape Navigator, and today powers Firefox
JavaScriptCore — open source, marketed as Nitro and developed by Apple for Safari
KJS — KDE’s engine originally developed by Harri Porten for the KDE project’s Konqueror web browser
Chakra (JScript9) — Internet Explorer
Chakra (JavaScript) — Microsoft Edge
Nashorn, open source as part of OpenJDK, written by Oracle Java Languages and Tool Group
JerryScript — is a lightweight engine for the Internet of Things.
36.what is an interpreted language
An interpreted language is a type of programming language for which most of its implementations execute instructions directly and freely, without previously compiling a program into machine-language instructions. //wiki
Php
1.What is php? What is the full-form of php?
PHP is a server side scripting language. that is used to develop Static websites or Dynamic websites or Web applications. PHP stands for Hypertext Pre-processor, that earlier stood for Personal Home Pages.
2.What does it mean by server side language?
Server side language is used to write programs that run on server side. These programs handle work like database queries, file creation, processing user queries.
3.what are the things that php can do?
- You can generate pages and files dynamically.
- You can create, open, read, write and close files on the server.
- You can collect data from a web form such as user information, email, phone no, etc.
- You can send emails to the users of your website.
- You can send and receive cookies to track the visitor of your website.
- You can store, delete, and modify information in your database.
- You can restrict unauthorized access to your website.
You can encrypt data for safe transmission over the internet.
//https://www.tutorialrepublic.com/php-tutorial/
4.How to get data from a form submitted by post method?
$_POST[] is a superglobal that gets the user data submitted through post method.
Example:
<form action=”” method=”post”>
<input type=”text” id=”name” name=”name”>
<input type=”submit” name=”submit”>
</form>
<?php
echo $_POST[‘name’];
?>
5.How to get data from a form submitted by get method?
$_GET[] is a superglobal that gets the user data submitted through get method.
Example:
<form action=”” method=”get”>
<input type=”text” id=”name” name=”name”>
<input type=”submit” name=”submit”>
</form>
<?php
echo $_GET[‘name’];
?>
6.How to know if the form has been submitted?
For general check if there was a POST action use:
if (!empty($_POST))
or
if ($_SERVER['REQUEST_METHOD'] == 'POST')
Use GET instead of POST if the form has been submitted by GET method.
7.what does isset method do?
The isset method is used to check whether the variable has been set or not. Returns true if the variable has been set, false otherwise.
Example:
isset($car);
7.What is empty method?
The empty() function is used to check whether a variable is empty or not.Returns true if the variable is empty, false otherwise.
Example:
empty($car);
8.How to connect to the database?
Ways to make a connection to database are:
MySQLi (object-oriented)
MySQLi (procedural)
PDO
Object oriented:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
Procedural:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
9.How to insert data in a table?
The INSERT INTO statement is used to add new records to a MySQL table:
INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)
Example:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
try {
$conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>
10.How to get data from a table?
The SELECT statement is used to select data from one or more tables:
SELECT column_name(s) FROM table_name
Example:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
11.How to delete a row from a table?
The DELETE statement is used to delete records from a table:
DELETE FROM table_name
WHERE some_column = some_value
Example: <?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// sql to delete a record
$sql = "DELETE FROM MyGuests WHERE id=3";
if ($conn->query($sql) === TRUE) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $conn->error;
}
$conn->close();
?>
12.How to update a row from a table?
The UPDATE statement is used to update existing records in a table:
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
Example:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>
13.How to get a count of a similar string or a value from a table?
The COUNT() function returns the number of records returned by a select query.
COUNT(expression);
Example:
"SELECT COUNT(*) FROM Data WHERE Firstname='ram'"
14.What is join?
The joins can retrieve the data from more than one table.
(INNER) JOIN: Returns records that have matching values in both tables
LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table
RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table
FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table
Example: SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID
//w3 schools
15.How to compare a value to a column?
The WHERE clause is used to match the value from columns from the table.
Example:
SELECT column1, column2, ...
FROM table_name
WHERE condition;
16.What is $_REQUEST in php?
$_REQUEST is a superglobal that gets the user data submitted through both get and post method.
Example:
<form action=”” method=”post”>
<input type=”text” id=”name” name=”name”>
<input type=”submit” name=”submit”>
</form>
<?php
echo $_REQUEST[‘name’];
?>
17.What are superglobals in php?
The superglobals are predefined variables that are available in any scope class or file, without having to do anything special.
The PHP superglobal variables are:
$GLOBALS
$_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION
18.What is a constant? How to define constant in php?
Constants are variables that cannot be changed once they are defined.
They are defined like this. define("variable name", "variable value");
19.How to navigate to a different page using php?
header() is used to send a raw HTTP header.
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. //php.net
Example:
header('Location: http://www.example.com/');
20.What are the types of variables in php?
String.
Integer.
Float (floating point numbers - also called double)
Boolean.
Array.
Object.
NULL.
Resource.
21.What are string methods in php?
addcslashes — Quote string with slashes in a C style
addslashes — Quote string with slashes
bin2hex — Convert binary data into hexadecimal representation
chop — Alias of rtrim
chr — Generate a single-byte string from a number
chunk_split — Split a string into smaller chunks
convert_cyr_string — Convert from one Cyrillic character set to another
convert_uudecode — Decode a uuencoded string
convert_uuencode — Uuencode a string
count_chars — Return information about characters used in a string
crc32 — Calculates the crc32 polynomial of a string
crypt — One-way string hashing
echo — Output one or more strings
explode — Split a string by a string
fprintf — Write a formatted string to a stream
get_html_translation_table — Returns the translation table used by htmlspecialchars and htmlentities
hebrev — Convert logical Hebrew text to visual text
hebrevc — Convert logical Hebrew text to visual text with newline conversion
hex2bin — Decodes a hexadecimally encoded binary string
html_entity_decode — Convert HTML entities to their corresponding characters
htmlentities — Convert all applicable characters to HTML entities
htmlspecialchars_decode — Convert special HTML entities back to characters
htmlspecialchars — Convert special characters to HTML entities
implode — Join array elements with a string
join — Alias of implode
lcfirst — Make a string's first character lowercase
levenshtein — Calculate Levenshtein distance between two strings
localeconv — Get numeric formatting information
ltrim — Strip whitespace (or other characters) from the beginning of a string
md5_file — Calculates the md5 hash of a given file
md5 — Calculate the md5 hash of a string
metaphone — Calculate the metaphone key of a string
money_format — Formats a number as a currency string
nl_langinfo — Query language and locale information
nl2br — Inserts HTML line breaks before all newlines in a string
number_format — Format a number with grouped thousands
ord — Convert the first byte of a string to a value between 0 and 255
parse_str — Parses the string into variables
print — Output a string
printf — Output a formatted string
quoted_printable_decode — Convert a quoted-printable string to an 8 bit string
quoted_printable_encode — Convert a 8 bit string to a quoted-printable string
quotemeta — Quote meta characters
rtrim — Strip whitespace (or other characters) from the end of a string
setlocale — Set locale information
sha1_file — Calculate the sha1 hash of a file
sha1 — Calculate the sha1 hash of a string
similar_text — Calculate the similarity between two strings
soundex — Calculate the soundex key of a string
sprintf — Return a formatted string
sscanf — Parses input from a string according to a format
str_getcsv — Parse a CSV string into an array
str_ireplace — Case-insensitive version of str_replace
str_pad — Pad a string to a certain length with another string
str_repeat — Repeat a string
str_replace — Replace all occurrences of the search string with the replacement string
str_rot13 — Perform the rot13 transform on a string
str_shuffle — Randomly shuffles a string
str_split — Convert a string to an array
str_word_count — Return information about words used in a string
strcasecmp — Binary safe case-insensitive string comparison
strchr — Alias of strstr
strcmp — Binary safe string comparison
strcoll — Locale based string comparison
strcspn — Find length of initial segment not matching mask
strip_tags — Strip HTML and PHP tags from a string
stripcslashes — Un-quote string quoted with addcslashes
stripos — Find the position of the first occurrence of a case-insensitive substring in a string
stripslashes — Un-quotes a quoted string
stristr — Case-insensitive strstr
strlen — Get string length
strnatcasecmp — Case insensitive string comparisons using a "natural order" algorithm
strnatcmp — String comparisons using a "natural order" algorithm
strncasecmp — Binary safe case-insensitive string comparison of the first n characters
strncmp — Binary safe string comparison of the first n characters
strpbrk — Search a string for any of a set of characters
strpos — Find the position of the first occurrence of a substring in a string
strrchr — Find the last occurrence of a character in a string
strrev — Reverse a string
strripos — Find the position of the last occurrence of a case-insensitive substring in a string
strrpos — Find the position of the last occurrence of a substring in a string
strspn — Finds the length of the initial segment of a string consisting entirely of characters contained within a given mask
strstr — Find the first occurrence of a string
strtok — Tokenize string
strtolower — Make a string lowercase
strtoupper — Make a string uppercase
strtr — Translate characters or replace substrings
substr_compare — Binary safe comparison of two strings from an offset, up to length characters
substr_count — Count the number of substring occurrences
substr_replace — Replace text within a portion of a string
substr — Return part of a string
trim — Strip whitespace (or other characters) from the beginning and end of a string
ucfirst — Make a string's first character uppercase
ucwords — Uppercase the first character of each word in a string
vfprintf — Write a formatted string to a stream
vprintf — Output a formatted string
vsprintf — Return a formatted string
wordwrap — Wraps a string to a given number of characters
22.What are array methods in php?
array_change_key_case — Changes the case of all keys in an array
array_chunk — Split an array into chunks
array_column — Return the values from a single column in the input array
array_combine — Creates an array by using one array for keys and another for its values
array_count_values — Counts all the values of an array
array_diff_assoc — Computes the difference of arrays with additional index check
array_diff_key — Computes the difference of arrays using keys for comparison
array_diff_uassoc — Computes the difference of arrays with additional index check which is performed by a user supplied callback function
array_diff_ukey — Computes the difference of arrays using a callback function on the keys for comparison
array_diff — Computes the difference of arrays
array_fill_keys — Fill an array with values, specifying keys
array_fill — Fill an array with values
array_filter — Filters elements of an array using a callback function
array_flip — Exchanges all keys with their associated values in an array
array_intersect_assoc — Computes the intersection of arrays with additional index check
array_intersect_key — Computes the intersection of arrays using keys for comparison
array_intersect_uassoc — Computes the intersection of arrays with additional index check, compares indexes by a callback function
array_intersect_ukey — Computes the intersection of arrays using a callback function on the keys for comparison
array_intersect — Computes the intersection of arrays
array_key_exists — Checks if the given key or index exists in the array
array_key_first — Gets the first key of an array
array_key_last — Gets the last key of an array
array_keys — Return all the keys or a subset of the keys of an array
array_map — Applies the callback to the elements of the given arrays
array_merge_recursive — Merge one or more arrays recursively
array_merge — Merge one or more arrays
array_multisort — Sort multiple or multi-dimensional arrays
array_pad — Pad array to the specified length with a value
array_pop — Pop the element off the end of array
array_product — Calculate the product of values in an array
array_push — Push one or more elements onto the end of array
array_rand — Pick one or more random keys out of an array
array_reduce — Iteratively reduce the array to a single value using a callback function
array_replace_recursive — Replaces elements from passed arrays into the first array recursively
array_replace — Replaces elements from passed arrays into the first array
array_reverse — Return an array with elements in reverse order
array_search — Searches the array for a given value and returns the first corresponding key if successful
array_shift — Shift an element off the beginning of array
array_slice — Extract a slice of the array
array_splice — Remove a portion of the array and replace it with something else
array_sum — Calculate the sum of values in an array
array_udiff_assoc — Computes the difference of arrays with additional index check, compares data by a callback function
array_udiff_uassoc — Computes the difference of arrays with additional index check, compares data and indexes by a callback function
array_udiff — Computes the difference of arrays by using a callback function for data comparison
array_uintersect_assoc — Computes the intersection of arrays with additional index check, compares data by a callback function
array_uintersect_uassoc — Computes the intersection of arrays with additional index check, compares data and indexes by separate callback functions
array_uintersect — Computes the intersection of arrays, compares data by a callback function
array_unique — Removes duplicate values from an array
array_unshift — Prepend one or more elements to the beginning of an array
array_values — Return all the values of an array
array_walk_recursive — Apply a user function recursively to every member of an array
array_walk — Apply a user supplied function to every member of an array
array — Create an array
arsort — Sort an array in reverse order and maintain index association
asort — Sort an array and maintain index association
compact — Create array containing variables and their values
count — Count all elements in an array, or something in an object
current — Return the current element in an array
each — Return the current key and value pair from an array and advance the array cursor
end — Set the internal pointer of an array to its last element
extract — Import variables into the current symbol table from an array
in_array — Checks if a value exists in an array
key_exists — Alias of array_key_exists
key — Fetch a key from an array
krsort — Sort an array by key in reverse order
ksort — Sort an array by key
list — Assign variables as if they were an array
natcasesort — Sort an array using a case insensitive "natural order" algorithm
natsort — Sort an array using a "natural order" algorithm
next — Advance the internal pointer of an array
pos — Alias of current
prev — Rewind the internal array pointer
range — Create an array containing a range of elements
reset — Set the internal pointer of an array to its first element
rsort — Sort an array in reverse order
shuffle — Shuffle an array
sizeof — Alias of count
sort — Sort an array
uasort — Sort an array with a user-defined comparison function and maintain index association
uksort — Sort an array by keys using a user-defined comparison function
usort — Sort an array by values using a user-defined comparison function
23.What is the difference between include and require?
include | require |
If the file missing, the script does not stop, it just gives warning about the missing file. | If the file is missing, the require function gives fatal error and the script stops executing |
Include functions can be used in loops or in control structures. | Require functions cannot be used in loops or in control structures. |
0 Replies to “Question And Answers Of PHP, Javascript, CSS, HTML Latest Asked In Interview.”
Leave a Reply
Your email address will not be published.