Skip to main content

PHP Quiz for Freshers with one Years of experience

Dear Candidate,

WebSpecia wishes you all the best for this PHP quiz for Freshers. Go ahead and test how much PHP you have learnt. 

This quiz is designed to have an overview of the knowledge of a PHP fresher. If you have one or less than one year of experience, this is the best way to know how deeply you know about the concept of PHP programming.

Go head, fill your name and email ID to begin with the questions.

What does PHP stand for?
PHP is a closed source software?
TRUE/FALSE: PHP is a server side language.
What is the correct way to end a PHP statement?
PHP server scripts are surrounded by delimiters, which?
How do you write "Hello World" in PHP
All variables in PHP start with which symbol?
The PHP syntax is most similar to:
How do you get information from a form that is submitted using the "get" method?
When using the POST method, variables are displayed in the URL:
In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings:
Include files must have the file extension ".inc"
What is the correct way to include the file "" ?

What is the correct way to create a function in PHP?

What is the correct way to open the file "time.txt" as readable?
PHP allows you to send emails directly from a script
Which superglobal variable holds information about headers, paths, and script locations?
What is the correct way to add 1 to the $count variable?
What is a correct way to add a comment in PHP?
PHP can be run on Microsoft Windows IIS(Internet Information Server):
The die() and exit() functions do the exact same thing.
Which one of these variables has an illegal name?
The setcookie() function must appear BEFORE the tag.
In PHP, the only way to output text is with echo.
How do you create an array in PHP?

The if statement is used to execute some code only if a specified condition is true
Which operator is used to check if two values are equal and of same data type?

Leaderboard for WebSpecia PHP Quiz (Fresher)

1. Dev-130 Points
2. subbarayal-105 Points
3. Pritam Shastrakar-100 Points
4. sai-95 Points
5. dasda-95 Points
php interview

Basic PHP Interview questions with answers for Freshers

php interviewCracking a PHP Interview at a reputed company requires strong knowledge of trending topics in the language. Freshers are asked basic PHP questions that are needed while working on live projects. So Interviewee must have the knowledge of the popular and trending topics of the industry. Here we have summerise the most commonly asked PHP interview questions for freshers along with Interview tips.

Most common PHP Interview Questions for freshers

If you are applying as a fresher you must be clear with the following questions/topics in order to qualify.

1. What is PHP?


  • PHP or “PHP: Hypertext Preprocessor” is a server side scripting language.
  • It is usesd to develop web applications.
  • PHP is an Object Oriented Programming Language (OOP).
  • Apart from dynamic websites, PHP is used to create many popular CMS such as WordPress, OSCommerce, Joomla etc.
    (You might get your next question on OOP, which is a very important topic. I have described it below)

2. Tell me some popular usages of PHP?

Below are some common uses of PHP −

  • You add, delete, modify elements within your database thru PHP.
  • PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them.
  • It can access cookies variables and set cookies.
  • By using PHP, you can restrict users to access some pages of your website.
  • PHP can encrypt data.
  • PHP can handle forms, i.e. gather data from files, save data to a file, thru email you can send data, return data to the user.

    3. What is echo in PHP and tell me the difference between echo & print?

  • echo & print both are used to get output. echo has no return value where as print has a return value of 1.
  • echo is faster than print
  • echo can take multiple parameters where as print takes only one argument
  • print is not actually a real function, It is a language construct. So you can use with out parentheses with its argument list.
    Example print(‘PHP Interview questions’);
    print ‘Job Interview ‘); The same is not true for echo.
  • Read more on print & echo here

4. Define include() & require() and their features.

  • We can include a file using “include() ” or “require()” function with file path as its parameter: such as : include (filename.php); or require(myfile.php);
  • include() and require() both are used to include a file while executing the current file.
  • If the include file is missing, the script will show warning message on execution but if we use require(), the script will show a fatal error on execution.

5. Explain GET & POST method in forms?

  • Both GET & POST methods are used to transfer data on a form.
  • Using GET method, you can only send 1024 bytes of data, however POST method can transfer any amount of data.
  • POST is secure than GET. As when you use GET method, data is displayed in the URL section. That is the reason we donot use GET while sending important information (such as passwords).
  • GET method creates a bookmarkable URL where POST doesn’t
  • You can set cache while using GET but the same is untrue while using POST.

 Tips from Interviewers

I have been into the industry for over 6 years & as an interviewer, the goal is to check the concept of the candidate by asking relevent questions on different topics. – Piyush Gupta, Senior Developer

 For PHP developers, the Interview starts with some basic questions but we cover all the aspects of PHP programming to know how deep your knowledge is. So donot lose hope when you find some tough questions from interviewer. –Deepak Kumar, PHP Developer

Recent search terms:

  • php programming interview questions and answers for freshers
  • PHP fresher interview question
  • php interview questions and answers for freshers
  • php interview questions for fresher
  • how to crack interview for php in company

How to make pyramid with while loop in PHP

We need to print a Pyramid which prints stars so that a pryamid could be printed.

To do so, we need to print 1 star in the first line and 2 in the second line, 3 in the thrid line and so on. We also need to keep it in mind that the star will be printed in the center, so that it could form a triangular shape of pyramid.

echo "&nbsp;&nbsp;";
$d = 1;
    echo "*&nbsp;&nbsp";
echo "&nbsp;&nbsp;";


There are three loops used in this program. First one is the outer one which is i, to create the horizontal row second one is $c which prints only spaces The third one is $d which prints stars according to demand.

The $c & $d are inside the $i loop, for every $i loop which prints horizontal line, the $c and $d will run just once to print space and * and then the <br/ >tag in the end will run once so that the cursor will go down to print another line.

Recent search terms:

  • how to print star second row in php with explanation
  • php program to print a stars in paramid?
  • php while loop pyramid
  • pyramid program in php using for loop