0% found this document useful (0 votes)
16 views14 pages

PHP Freshers Interview Questions Set A

The document outlines a set of questions organized into five sections: HTML, CSS, PHP, CodeIgniter, JavaScript, and MySQL, aimed at evaluating knowledge in these areas. It includes specific questions and answers related to each section, along with a brief introduction and instructions for the evaluation process. The document also contains personal information about the individual being evaluated, including their name, contact details, and qualifications.

Uploaded by

Srijit Ghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views14 pages

PHP Freshers Interview Questions Set A

The document outlines a set of questions organized into five sections: HTML, CSS, PHP, CodeIgniter, JavaScript, and MySQL, aimed at evaluating knowledge in these areas. It includes specific questions and answers related to each section, along with a brief introduction and instructions for the evaluation process. The document also contains personal information about the individual being evaluated, including their name, contact details, and qualifications.

Uploaded by

Srijit Ghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Set A Ver 2.

4 Page 1 of 14

Hi,

The questions are organized into 5 sections.

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.

Name: Phiroze Chowdhury

Contact No: 7003772464

Email Id: [email protected]

Highest Qualification: MCA

Language / Concepts Do you know [Yes/No] Real Project

Experience [Y/N]

HTML yes y

CSS yes y

PHP yes y

CodeIgniter no n

Javascript yes y

JSON yes n

API Creation yes n

API Consuming yes y

mySql yes y
Set A Ver 2.4 Page 2 of 14

Section 1 - HTML

1. What are different types of lists in HTML?

ordered list (ol) unordered list(ul)

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

4. How to include JavaScript code in HTML?

<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

1, HTML, Front End

2, CSS, Front End

3, Php, Back End


Set A Ver 2.4 Page 3 of 14

<table>

<tr>

<th>S.no.</th>

<th>Language</th>

<th> Mostly used for.</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>

6. How to include CSS in a webpage?

<link rel=”stylesheet” href=”cssFile.css”>


Set A Ver 2.4 Page 4 of 14

Section 2 - CSS

1. Give on example each of Element Selector, Class selector and ID selector?

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%;

border: 1px solid blue}

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 element is used to style a specific part of any element.example: p::first-line.

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;}

6. What does !important mean in CSS?

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

1. What will be the output of following script?

<?php

$variable = "name";

$statement = 'Variable has value: $variable';

print($statement);

print " ";

$statement = " Variable has value: $variable ";

print($statement);

?>

Variable has value: $variable Variable has value: name

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

3. What is the difference between “echo” and “print”?

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.

4. What is the use of session and cookies?

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.

5. How to escape data before storing it in the database?

htmlspecialcharecters($var) and htmlentities($var) this php functions


can be used to escape data before storing into database.
Set A Ver 2.4 Page 7 of 14

6. How to remove escape characters from a string?

we can remove the escape character from a string stoed in a variable $str by
stri[slashes($str)

7. How can you pass a variable by reference?

using ‘&’ before the variable we can pass it by references.

example: funcName(&$str)

8. write code using ternary conditional operator to:


if $myVariable holds value 10, then print "Value is 10" else print "Value is not 10"

print($myVariable==10? "Value is 10": "Value is not 10");

9. When to use $_FILES[‘userfile’][‘name’] and when to use $_FILES[‘userfile’]


[‘tmp_name’]

$_FILES["file"]["name"] //stores the original filename from the client $_FILES["file"]


["tmp_name"] //stores the name of the temporary file in the server

10. What will be the output of following script

<?php

$var =10;

function myFunction(){

$var = 20;

echo $var;

myFunction();
Set A Ver 2.4 Page 8 of 14

echo $var;

20 10

11. How can we determine whether a variable is set or not?

isset() function is used

12. Write php script to display a form with following fields. The form should send data
to /saveme.php.

Name -- input cannot be blank

Email-Id -- should be valid

Contact Number -- should contain only numbers

<form action=”/saveme.php” method=”post”>

name:<input type=”text” name=”name” required>

Email-id:<input type=”email” name=”mail”>

Contact Number: <input type=”number” name=”contact”>

<input type=”submit”>

</form>

13. Convert the received data in saveme.php to JSON String

14. how to connect with mysql?

$con=mysqli_connect(“hostname”,”username”,”password”,”database_name”)

15. How to get the date in following format.


Today's Date is 2025-07-25
$date=date_create(“2025-07-25”);

16. How to convert above date stored in variable to “dd/mm/yyyy” format.

$datevar= date_format($date,"Y/m/d ");

17. How is a constant declared in a PHP script?


Set A Ver 2.4 Page 9 of 14

define(name, value, is_case_sensitive) this is the way to declare a constant


Set A Ver 2.4 Page 10 of 14

Section 4 – CodeIgniter
1. Explain briefly Model, View, Controller?

2. What is the purpose of $this?

3. How to extend a class in CodeIgniter?

4. How to display and log errors?

5. How to pass an array from the controller to view?

6. How to add session data in CodeIgniter?

7. How to Remove session data in CodeIgniter?


Set A Ver 2.4 Page 11 of 14

Section 4 – JavaScript

1. What is NaN property in JavaScript?


It is a primitive datatype in javascript. NaN stands for not a number. when
we try to use string objects as a number we get a NaN error.
2. Explain call(), apply() and, bind() methods.

3. Rewrite the following function using arrow function.

function myFunction(a) {

return a * 2;

const myFunction=a=>a*2

4. Accept the output of following function using object Destructuring?

function myValues() {

const value1 = 'username';

const value2 = 'password';

return [value1,value2];

var {val1,val2}=myValues();

5. What will be the output for following?

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()=>{

const res=await axios.get(apiUrl) //getting response as promise

.then((res)=>JSON.parse(res)) // parsing data into json

.then(data=>console.log(data)) // printing in console


Set A Ver 2.4 Page 12 of 14

}
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

Student Name - length 100 chars

Email id - length 100 chars

2. Books table

Book Name length 100 chars

borrowed_by_student_id integer

isReturned smallint with 0 as default value

borrowed_on date

create table students (Name varchar2(100), emailid varchar2(100)


primary key);

create table Books(Book_Name varchar2(100),


borrowed_by_student_id INTEGER, isReturned,borrowed_on date);

2. Write statement to insert following data in students table.

Name - John Doe

emailid - [email protected]

oldemailid – null

insert into students(Name,emailid,oldemailid )values(John


Doe,[email protected],null)

3. write sql statement to show the name of student with the book name
which they have borrowed from Library

select name, Book_Name from students natural join books where


studentid=borrowed_by_student_id;

4. Write sql statement to select all records from students table which does
not have an email id in ascending order of student name.

select * from students order by name where where emailid=null

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.

7. write sql statement to select first 10 students from students table.

select top 3 * from students

8. write sql statement to find duplicate books from books table.

select * from books group by book_name having


count(book_name)>1

Thank you.

You might also like