core php interview question
  1. What is PHP?PHP is a server side scripting language commonly used for web applications. PHP has many frameworks and cms for creating websites.Even a non technical person can cretae sites using its CMS.WordPress,osCommerce are the famus CMS of php.It is also an object oriented programming language like java,C-sharp etc.It is very eazy for learning
  2. Who is known as the father of PHP?

    Rasmus Lerdorf

  3. What was the old name of PHP?

    The old name of PHP was Personal Home Page.

  4. Explain the difference between static and dynamic websites?

    In static websites, content can’t be changed after running the script. You can’t change anything on the site. It is predefined.In static website you need to change manually.

    In dynamic websites, content of script can be changed at the run time. Its content is regenerated every time a user visit or reload. Google, yahoo and every search engine is the example of dynamic website.

  5. Explain the difference between PHP4 and PHP5.

    PHP4 doesn’t support oops concept and uses Zend Engine 1.

    PHP5 supports oops concept and uses Zend Engine 2.

  6. What are the popular frameworks in PHP?

    • CakePHP
    • Larval
    • CodeIgniter
    • Yii 2
    • Symfony
    • Zend Framework etc.
  7. What is the use of “echo” in php?It is used to print a data in the webpage, Example: <?php echo ‘Php Training in Patna’; ?> , The following code print the text in the webpage
  8. 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.
  9. PHP $ and $$ Variables

    The $var (single dollar) is a normal variable with the name var that stores any value like string, integer, float, etc.

    The $$var (double dollar) is a reference variable that stores the value of the $variable inside it.

  10. What’s the difference between include and require?If 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.
  11. require_once(), require(), include().What is 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.
  12. Differences between GET and POST methods ?We can send 1024 bytes using GET method but POST method can transfer large amount of data and POST is the secure method than GET method .
  13. What is the purpose of the superglobal variable called $_SERVER ?$_SERVER is an array and it holds the information about paths, headers, and script locations.
  14. How to Detecting request type in PHP ?By using $_SERVER['REQUEST_METHOD'] method
  15. How to declare an array in php?Eg : var $arr = array(‘apple’, ‘grape’, ‘lemon’);
  16. How can PHP interact to Javascript ?PHP cannot interact with javascript directly, since php is server side programming language when javascript is a client side programming language. However we can embbed the php variable values to a javascript code section when it complile at the server or javascript can communicate to a php page via http calls

    NB: Javascript can run at the server side as well using Node.js Server

  17. How to manipulate image files using php ?GD is library that providing image manipulation capabilities to php, so that we can do so many things such as crop, merge, change grayscale and much more with GD functions
  18. How to manipulate video files using php ?There is no inbuilt library available in php, However there are some open source libraries that providing these features

    FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. We can install this extension in php and use to do variety of tasks

  19. What is cron jobs ?Cron jobs are scheduled tasks, executed on regular time intervals set by the developer. They work by running preferred scripts. We can set the time intervals for running these scripts. Its not a part of php compiler, We have several ways to do this based on the platform or the hostign control panel type
  20. How to sent a POST request from php ( Without using any html ) ?You could use cURL, that allows you to connect and communicate to many different types of servers with many different types of protocols such as http, https, ftp etc.
  21. What is the use of ‘print’ in php?This is not actually a real function, It is a language construct. So you can use with out parentheses with its argument list.
    Example print(‘Latest PHP Interview questions’);
    print ‘Job Interview ‘);
  22. What is use of in_array() function in php ?in_array used to checks if a value exists in an array
  23. What is use of count() function in php ?count() is used to count all elements in an array, or something in an object
  24. What’s the difference between include and require?It’s how they handle failures. If 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.
  25. What is PEAR in PHP?

    PEAR is a framework and repository for reusable PHP components. PEAR stands for PHP Extension and Application Repository. It contains all types of PHP code snippets and libraries.It also provides a command line interface to install “packages” automatically.