PHP Freshers Interview Questions Set A
PHP Freshers Interview Questions Set A
4 Page 1 of 14
Hi,
Try to attempt at least 10 questions from PHP Section and 5 questions each from other sections.
You will be evaluated based on answered questions only.
Best of Luck.
Experience [Y/N]
HTML yes y
CSS yes y
PHP yes y
CodeIgniter no n
Javascript yes y
JSON yes n
mySql yes y
Set A Ver 2.4 Page 2 of 14
Section 1 - HTML
2. Define multipart form data, when to use this type of form data?
The ENCTYPE attribute of <form> tag specifies the method of encoding for the
form data. It is one of the two ways of encoding the HTML form. It is specifically
used when file uploading is required in HTML form. It sends the form data to server
in multiple parts because of large size of file
example
<form action="uploading.php" method="POST"
enctype="multipart/form-data">
<input type="file" name="fileup" /> <br><br>
<button>upload</button>
</form>
3. How can we club two or more rows or columns into a single row or column in an HTML
table?
for merging columns we use the attribute <colspan> and for merging rows <rowspan>
attribute can be used
<script src=”scriptName.js”> </script> this tag can be used to include a javascript file and
<script>//javascript code</script> this can be used to include javascript code inside a html
file.
5. Write html to convert the below data into Tabular format in HTML5?
S.no., Language, Mostly used for
<table>
<tr>
<th>S.no.</th>
<th>Language</th>
</tr>
<tr>
<td> 1</td>
<td> HTML</td>
<td>Front End</td>
</tr>
<tr>
<td> 2</td>
<td> CSS</td>
<td>Front End</td>
</tr>
<tr>
<td> 3</td>
<td> Php</td>
<td>Back End</td>
</tr>
</table>
Section 2 - CSS
p{color:white}
.cls{width:20%}
#ids{display:none}
2. What is the difference between inline, inline-block, and block? Give 1 example each of
these.
Inline elements like span do not respect width, height, padding or margins and the
elements are displayed side by side. Example: span
Inline block elements are also put side by side but the width, height, padding or
margins work for this display option.
.box{display:inline-block;
width:50%;
bock elements also respect all the properties like inline block, only the divisions are
set as each at a line. they are not kept side by side. div has inbuilt block property
3. What are Pseudo elements and Pseudo classes? Give 1 example for each.
A Pseudo class is used to style a specific state of any html element. example:
h1:hover.
4. What is a z-index
Z-index is a CSS property that defines the order of overlapping HTML elements.
Elements with a higher index will be placed on top of elements with a lower
index.
5. How to center align a div inside another div, using Flexbox or Grid?
.outerdiv{
display:flex;
align-items:center;
Set A Ver 2.4 Page 5 of 14
justify-content:center;}
It means the specific style on the element has the highest priority no other styling can
overlap that styling property.
Set A Ver 2.4 Page 6 of 14
Section 3 - PHP
<?php
$variable = "name";
print($statement);
print($statement);
?>
2. how to display This is string1 and this is string2 on screen? When $string1 has "This
is string1 " and $string2 has "and this is string2".
echo $string1.$string2
echo has no return value but print returns 1. echo can take multiple parameters
but print can take only one. echo is faster than print.
Cookies and Sessions are used to store information. Cookies are only
stored on the client-side machine, while sessions get stored on the client as
well as a server. A session creates a file in a temporary directory on the
server where registered session variables and their values are stored.
we can remove the escape character from a string stoed in a variable $str by
stri[slashes($str)
example: funcName(&$str)
<?php
$var =10;
function myFunction(){
$var = 20;
echo $var;
myFunction();
Set A Ver 2.4 Page 8 of 14
echo $var;
20 10
12. Write php script to display a form with following fields. The form should send data
to /saveme.php.
<input type=”submit”>
</form>
$con=mysqli_connect(“hostname”,”username”,”password”,”database_name”)
Section 4 – CodeIgniter
1. Explain briefly Model, View, Controller?
Section 4 – JavaScript
function myFunction(a) {
return a * 2;
const myFunction=a=>a*2
function myValues() {
return [value1,value2];
var {val1,val2}=myValues();
function product(a) {
let c;
return a * c ;
NaN
6. how to Call an API in Javascript using Ajax / Axios, and parse the response?
const getData = async()=>{
}
Set A Ver 2.4 Page 13 of 14
Section 5 – MySql
1. Write sql script to Create following tables, fields along with the provided
data types. Add suitable primary keys also
1. students table
2. Books table
borrowed_by_student_id integer
borrowed_on date
emailid - [email protected]
oldemailid – null
3. write sql statement to show the name of student with the book name
which they have borrowed from Library
4. Write sql statement to select all records from students table which does
not have an email id in ascending order of student name.
5. Write sql script for inserting the rows of point 2 using transaction.
Set A Ver 2.4 Page 14 of 14
6. write sql statement to change value of oldemailid field to new email id.
Thank you.