Prototype Phase and Final Viva Questions
Prototype Phase and Final Viva Questions
10) Open login form in password input password in not showing. Show
thepassword?
Just change the input type password > text
Now it’s visible to you
With PHP:
<?php
If(5>2)
echo “5 is greater than 2”;
else
echo “5 is not greater than 2”;
?>
14) Design two input that take two number from user and when user click on
buttonthen display the sum of these number?
You can use any of the language for this purpose:
With Javascript:
<input type="number" id="first">
<input type="number" id="second">
<input type="submit" onClick="show()">
<script>
function show(){
var a=document.getElementById("first").value;
var b=document.getElementById("second").value;
var c=(parseInt(a)+parseInt(b));
document.write(c);
}
</script>
With PHP:
<form method=”post”>
<input type=”number” name=”one”>
<input type=”number” name=”two”>
<input type=”submit” name=”submit” value=”Sum”>
</form>
<?php
If(isset($_POST[‘submit’])){
$one=$_POST[‘one’];
$two=$_POST[‘two’];
$c=$one+$two;
Asad Nawaz 03026692707
?>
16) How to define variable in PHP?
In PHP variable are define with $ (dollar) sign. This is the identify of variable.
<?php
$a=5;
$b=10;
?>
17) How to take sum of two number in PHP?
<?php
$a=5;
$b=10;
$c=$a+$b;
echo “sum of two number is =”.$c;
?>
18) PHP echo and print statement
They are both used to output data to the screen.
The differences are small: echo has no return value while print has a return value
of 1. echo can take multiple parameters while print can take on argument. Echo is
faster than print.
19) Comments in PHP
A comment in PHP code is a line that is not executed as a part of the program. Its
only purpose is to be read by someone who is looking at the code.
// this is single line comments
# this is also single line comment
/*
Multi-line comments
*/
20) PHP form handling
Result can be achieved using HTTP post method:
$_POST[‘’] Method
Result can be achieved using HTTP get method:
Asad Nawaz 03026692707
$_GET[‘’] Method
For better understanding please watch this video:
https://youtu.be/M2pbe1Afkx0
Do… while – through a block of code one, and then repeat the loop as long as the
specified condition is true.
For- loop through a block of code a specified number of items
Foreach – through a block of code for each element in an array
While loop syntax:
<?php
$x = 1;
while($x <= 5) {
echo "The number is: $x <br>";
$x++;
}
?>
do while loop syntax:
<?php
$x = 1;
do {
echo "The number is: $x <br>";
$x++;
} while ($x <= 5);
?>
For loop syntax:
<?php
for ($x = 0; $x <= 10; $x++) {
echo "The number is: $x <br>";
}
?>
Foreach loop syntax:
<?php
$colors = array("red", "green", "blue", "yellow");