PHP Questions & Answers (Compiled from UPSC, SSC ,PSC ,IBPS previous question papers)

  • What is Array in PHP

  • AArray stores collection of values. You can declare array in PHP as like this. $fruits = array(‘apple’, ‘grape’, ‘orange’);
  • What is the difference between GET and POST

  • AGet sends data upto 1024 bytes and limited. We cannot send sensitive data using get. Because the data will appear in browser url. Where as POST can send large amount of data and also suitable to send sensitive data (like passwords etc.)
  • What is a PHP Session

  • APHP Session is an object created by the PHP engine that persists data between HTTP requests
  • require_once(), require(), include().What is difference between them

  • Arequire() 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.
  • What's the difference between include and require

  • AIf the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
  • What is PHP

  • APHP is a server side scripting language commonly used for web applications. Acronym for PHP is Hypertext Preprocessor