PHP Basics



1. What is PHP?  

  • PHP stands for PHP: Hypertext Preprocessor
  • PHP is a server-side scripting language, like ASP
  • PHP scripts are executed on the server
  • PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
  • PHP is an open source software
  • PHP is free to download and use


2. What is a PHP File?  

  • PHP files can contain text, HTML tags and scripts
  • PHP files are returned to the browser as plain HTML
  • PHP files have a file extension of ".php", ".php3", or ".phtml"


3. Why PHP?  

  • PHP runs on different platforms (Windows, Linux, Unix, etc.)
  • PHP is compatible with almost all servers used today (Apache, IIS, etc.)
  • PHP is FREE to download from the official PHP resource: www.php.net
  • PHP is easy to learn and runs efficiently on the server side


4. What does the initials of PHP stand for?  

PHP means PHP: Hypertext Preprocessor.



5. Which programming language does PHP resemble to?  

PHP syntax resembles Perl and C


6. What does PEAR stands for?  

PEAR means "PHP Extension and Application Repository". it extends PHP and provides a higher level of programming for web developers.


7. What is the actually used PHP version?  

Version 5 is the actually used version of PHP.


8. How do you execute a PHP script from the command line?  

Just use the PHP command line interface (CLI) and specify the file name of the script to be executed as follows: [crayon-53e4764215d6a784973206/]


9. How to run the interactive PHP shell from the command line interface?  

Just use the PHP CLI program with the option -a as follows: [crayon-53e4764215d7e505856038/]


10. Is multiple inheritance supported in PHP?  

PHP includes only single inheritance, it means that a class can be extended from only one single class using the keyword 'extended'.


11. What is the meaning of a final class and a final method?  

'final' is introduced in PHP5. Final class means that this class cannot be extended and a final method cannot be overrided.


12. How comparison of objects is done in PHP5?  

We use the operator '==' to test is two object are instanced from the same class and have same attributes and equal values. We can test if two object are refering to the same instance of the same class by the use of the identity operator '==='.


13. How can PHP and HTML interact?  

It is possible to generate HTML through PHP scripts, and it is possible to pass informations from HTML to PHP.


14. What type of operation is needed when passing values through a form or an URL?  

If we would like to pass values througn a form or an URL then we need to encode and to decode them using htmlspecialchars() and urlencode().


15. How can PHP and Javascript interact?  

PHP and Javascript cannot directly interacts since PHP is a server side language and Javascript is a client side language. However we can exchange variables since PHP is able to generate Javascript code to be executed by the browser and it is possible to pass specific variables back to PHP via the URL.


16. 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.


17. What is difference between require_once(), require() and include() ?  

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.


18. 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 .


19. How to declare an array in php?  

var $arr = array('apple', 'grape', 'lemon');


20. 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.
print('PHP Interview questions');


.Net Interview Question

PHP Interview Question

Java Interview Question

AngularJS Interview Questions