We have top 10 PHP interview questions and answers prepared by experts from Outsource2global. We have taken full care to explain the best answers to all the questions.
What is measure difference between PHP and Java ?
Deployment area : –
PHP – Server-side scripting
JAVA – General-purpose programming
Language type –
Providing a rich set of APIs –
PHP – No
JAVA – Yes
What is way to encrypt a password using PHP ?
The crypt () – This function is used to create one-way encryption. It takes one input string and one optional parameter. The function is defined as:
crypt (input_string, salt)
How to submit a form without a submit button ?
We can submitted or posted form without the button in the following ways:
How can we increase the execution time of a PHP ?
30 seconds mentioned in the php.ini , It is default time allowed for a PHP script to execute is file. The function used is set_time_limit(int sec).If we passed value ‘0’, it takes unlimited time. It should be noted that if the default timer is set to 30 seconds and 20 seconds is specified in set_time_limit(), the script will run for 45 seconds.
We can increase the execution time in foll following ways –
Using the sleep() function in the PHP script
Using the set_time_limit() function
As we know that, The default limit is 30 seconds. The time limit can be set to zero to impose no time limit.
What is Zend Engine?
It is used internally by PHP as a compiler and runtime engine. PHP Scripts are loaded into memory and compiled into Zend OPCodes.
OPCodes are executed and the HTML generated is sent to the client system.
Which is best library used for PDF in PHP?
Using PDFlib version 6, The PDF functions in PHP can create PDF files . PDFlib offers an object-oriented API for PHP5 in addition to the function-oriented API for PHP4.
FPDF is a PHP class, which allows generating PDF files with PHP (without using PDFlib).
Explain about new features introduced in PHP7?
Zend Engine 3 performance improvements and 64-bit integer support on Windows
Uniform variable syntax
AST-based compilation process
Bitwise shift consistency across platforms
(Null coalesce) operator
Unicode codepoint escape syntax
Return type declarations
Scalar type (integer, float, string, and Boolean) declarations
What is htaccess? What is used for this ?
.htaccess is files that are configuration files of Apache Server it provide sa way to make configuration changes on a per-directory basis.
It containing one or more configuration directives and it placed in a particular document directory; This directives apply to that directory and all subdirectories thereof.
Its used for –
Is used for rewrite URL .
It makes the site password-protected.
It is used to restrict some IP addresses so that on these restricted IP addresses, the site will not open.
Exaplain about magic methods in PHP?
Magic methods always start with ‘__’, for example, __construct(). All magic methods need to be declared as public.
Thare are various types of magic methods available in php –