Top 15 Core PHP Interview questions and answers for freshers ?

php interview questions

 

(Image Source Pixbay)

PHP is a common language that helps a fresher candidate to get a job easily. A large number of jobs are available in the software market in PHP, but still, for this, you need some basic knowledge in order to qualify for the minimum technical qualification.

Here are a PHP Interview Questions which will help you to win interview session easily.

1.What is PHP and you tell me Something about PHP?

PHP is a server-side scripting language commonly used for creating dynamic web applications. PHP has their Code frameworks for example like(Laravel, Zend, CodeIgniter, Symphony, CakePHP) and Content Management Systems(WordPress, Drupal, Joomla) and ECommerce Platforms for Creating websites.

2.What is the use of “echo” in php?

It is used to print a data in the webpage, Example: <?php echo ‘Car insurance’; ? >, The following code print the text on the webpage

  1. How to include a file to a php page?

We can include a file using “include() ” or “require()” function with file path as its parameter.

  1. What’s the Main difference between the include() and require() functions?

They both include a specific file but on require the if the file can’t be included, a process will exit with a fatal error but in the same case in include statement may still pass and jump to the next step in the execution.

  1. What’s the Main difference between unset() and unlink()

unset() is used to destroy a variable whereas unlink() is used to destroy a file.

  1. require_once(), require(), include().What is the difference between them?

require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don’t include the file more times and you will not get the “function re-declared” error.

 

  1. Differences between GET and POST methods?

We can send 1024 bytes using GET method but POST method can transfer a large amount of data and POST is the secure method than GET method.

  1. How will you declare an array in php?

you can declare an array in php like in this way

var $arr = array(‘Php’, ‘java’, ‘ruby’)

 

  1. How can we retrieve the data in the result set of MySQL using PHP?
  2. mysql_fetch_row
    2. mysql_fetch_array
    3. mysql_fetch_object
    4. mysql_fetch_assoc

10.What is the difference between Session and Cookie?

The main difference between sessions and cookies is that sessions are stored on the server, and cookies are stored on the user’s computers in the text file format. Cookies can’t hold multiple variables while session can hold multiple variables.We can set expiry for a cookie, The session only remains active as long as the browser is open.Users do not have access to the data you stored in Session Since it is stored on the server.Session is mainly used for login/logout purpose while cookies using for user activity tracking

  1. How to set cookies in PHP?

Setcookie(“sample”, “ram”, time()+3600);

  1. How to redirect a page in php?

The following code can be used for it, header(“Location:index.php”);

  1. What is the use of isset() in php?

This function is used to determine if a variable is set and is not NULL

  1. What is the use of “enctype” attribute in an HTML form?

The enctype attribute determines how the form-data should be encoded when submitting it to the server. We need to set enctype as “multipart/form-data” when we are using a form for uploading files

  1. How will you generate random numbers using PHP?

The rand() function in PHP is used for generating a random number. This function can generate numbers within a given range.

 Source : phpinterviewquestions , technologyshouters

Shaheel is a Digital Marketing Consultant from Kolkata, India. He is also a Professional Trainer in this field of Digital Marketing. He is teaching and Working professional last 3 years.

About Shaheel Khan

Shaheel is a Digital Marketing Consultant from Kolkata, India. He is also a Professional Trainer in this field of Digital Marketing. He is teaching and Working professional last 3 years.

Shaheel is a Digital Marketing Consultant from Kolkata, India. He is also a Professional Trainer in this field of Digital Marketing. He is teaching and Working professional last 3 years.