*Friday CLOSED

Timings 10.00 am - 08.00 pm

Call : 021-3455-6664, 0312-216-9325 DHA 021-35344-600, 03333808376, ISB 03333808376

Web Development PHP Job Interview Questions and Answers Karachi Pakistan Dubai

PHP Job Interview Q&A

Top PHP Interview Questions and Answers

Here are the top 14 sample PHP interview questions and their answers framed by experts from Omni Academy who train for MySQL Training to give you an idea of the type of questions that may be asked in interviews. We have taken full care to give the best answers to all the questions. Do comment your thoughts. Happy job hunting!

Top Answers to PHP Interview Questions

1. Compare PHP and Java.

CriteriaPHPJava
Deployment areaServer-side scriptingGeneral-purpose programming
Language typeDynamically typedStatically typed
Providing a rich set of APIsNoYes

2. How can we encrypt a password using PHP?

The crypt () 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)

where input_string consists of the string that has to be encrypted and salt is an optional parameter. PHP uses DES for encryption. The format is as follows:





3. Explain how to submit a form without a submit button.

A form can be posted or submitted without the button in the following ways:

  • On the OnClick event of a label in the form, a JavaScript function can be called to submit the form.
    Example:
               document.form_name.submit()
  • Using a Hyperlink: On clicking the link, a JavaScript function can be called.

Example:





  • A form can be submitted in the following ways as well without using the submit button:
    • Submitting a form by clicking a link
    • Submitting a form by selecting an option from the drop-down box with the invocation of an onChange event
    • Using JavaScript:
document.form.submit();
  • Using header(“location:page.php”);

4. How can we increase the execution time of a PHP script?

  • The default time allowed for a PHP script to execute is 30 seconds mentioned in the php.ini file. The function used is set_time_limit(int sec). If the value passed is ‘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.
  • This time can be increased by modifying max_execution_time in seconds. The time must be changed keeping the environment of the server. This is because modifying the execution time will affect all the sites hosted by the server.
  • The script execution time can be increased by:
    • Using the sleep() function in the PHP script
    • Using the set_time_limit() function

The default limit is 30 seconds. The time limit can be set to zero to impose no time limit

5. What is Zend Engine?

Zend Engine is used internally by PHP as a compiler and runtime engine. PHP Scripts are loaded into memory and compiled into Zend OPCodes.

These OPCodes are executed and the HTML generated is sent to the client.

The Zend Engine provides memory and resource management and other standard services for the PHP language. Its performance, reliability, and extensibility have played a significant role in PHP’s increasing popularity.

6. What library is used for PDF in PHP?

The PDF functions in PHP can create PDF files using PDFlib version 6. PDFlib offers an object-oriented API for PHP5 in addition to the function-oriented API for PHP4.
There is also the » Panda module.

FPDF is a PHP class, which allows generating PDF files with pure PHP (without using PDFlib). F from FPDF stands for Free: we may use it for any requirement and modify it to suit our needs. FPDF requires no extension (except zlib to activate compression and GD for GIF support) and works with PHP4 and PHP5.

7. What are the new features introduced in PHP7?

  • Zend Engine 3 performance improvements and 64-bit integer support on Windows
  • Uniform variable syntax
  • AST-based compilation process
  • Added Closure::call()
  • Bitwise shift consistency across platforms
  • (Null coalesce) operator
  • Unicode codepoint escape syntax
  • Return type declarations
  • Scalar type (integer, float, string, and Boolean) declarations

8. What is htaccess? Why do we use it and where?

The .htaccess files are configuration files of Apache Server that provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory; the directives apply to that directory and all subdirectories thereof.

These .htaccess files are used to change the functionality and features of the Apache web server.

For instance:

  • The .htaccess file is used for URL rewrite.
  • It is used to make the site password-protected.
  • It can restrict some IP addresses so that on these restricted IP addresses, the site will not open.

9. What are magic methods?

Magic methods are member functions that are available to all the instances of a class. Magic methods always start with ‘__’, for example, __construct(). All magic methods need to be declared as public.

To use a method, it should be defined within the class or the program scope. Various magic methods used in PHP5 are:

  • __construct()
  • __destruct()
  • __set()
  • __get()
  • __call()
  • __toString()
  • __sleep()
  • __wakeup()
  • __isset()
  • __unset()
  • __autoload()
  • __clone()

10. What is meant by PEAR in PHP?

PEAR is an acronym for PHP Extension and Application Repository. The purpose of PEAR is to provide:

  • A structured library of open-sourced code for PHP users
  • A system for code distribution and package maintenance
  • A standard style for writing code in PHP
  • PHP Foundation Classes (PFC)
  • PHP Extension Community Library (PECL)
  • A website, mailing lists, and download mirrors to support the PHP/PEAR community

11. Explain soundex() and metaphone().

The soundex() function calculates the soundex key of a string. A soundex key is a 4-character long alphanumeric string that represents the English pronunciation of a word. The soundex() function can be used for spelling applications.

$str= “hello”;
Echo soundex($str);
?>

The metaphone() function calculates the metaphone key of a string. A metaphone key represents how a string sounds if it is pronounced by an English (native) person. This function can also be used for spelling applications.

echo metaphone(“world”);
?>

12. What is Smarty?

Smarty is a template engine written in PHP. Typically, these templates will include variables—like {$variable}—and a range of logical and loop operators to allow adaptability within the templates.

13. What is Memcache?

Memcache is a technology that caches objects in memory such that a web application can get to them really fast. It is used by sites, such as Digg, Facebook, and NowPublic, and is widely recognized as an essential ingredient in scaling any LAMP.

14. How can we execute a PHP script using a command line?

We just have to run the PHP CLI (Command-line Interface) program and provide the PHP script file name as the command-line argument, for example, php myScript.php, assuming php as the command to invoke the CLI program.

We have to keep in mind that if our PHP script is written for the Web CGI interface, it may not execute properly in the command-line environment.

Recommended Courses

Advanced Diploma in Web Development (Fed Govt. Program)

Digital Marketing Course

Social Media Marketing for Business Growth (2 Months Approx)

Search Engine Optimization – Advanced SEO(2 Months Approx)

Python programming – Mastering Paython

Mobile Application Development

Diploma in 3DS Max – Animation & Visualizer
Diploma in Graphics & Animation Course
AUTOCAD 2D 3D Course

sharing is caring
Print Friendly, PDF & Email

Leave a Reply


ABOUT US

OMNI ACADEMY & CONSULTING is one of the most prestigious Training & Consulting firm, founded in 2010, under MHSG Consulting Group aim to help our customers in transforming their people and business - be more engage with customers through digital transformation. Helping People to Get Valuable Skills and Get Jobs.

Read More

Contact Us

Get your self enrolled for unlimited learning 1000+ Courses, Corporate Group Training, Instructor led Class-Room and ONLINE learning options. Join Now!
  • Head Office: A-2/3 Westland Trade Centre, Shahra-e-Faisal PECHS Karachi 75350 Pakistan Call 0213-455-6664 WhatsApp 0334-318-2845, 0336-7222-191, +92 312 2169325
  • Gulshan Branch: A-242, Sardar Ali Sabri Rd. Block-2, Gulshan-e-Iqbal, Karachi-75300, Call/WhatsApp 0213-498-6664, 0331-3929-217, 0334-1757-521, 0312-2169325
  • ONLINE INQUIRY: Call/WhatsApp +92 312 2169325, 0334-318-2845, Lahore 0333-3808376, Islamabad 0331-3929217, Saudi Arabia 050 2283468
  • DHA Branch: 14-C, Saher Commercial Area, Phase VII, Defence Housing Authority, Karachi-75500 Pakistan. 0213-5344600, 0337-7222-191, 0333-3808-376
  • info@omni-academy.com
  • FREE Support | WhatsApp/Chat/Call : +92 312 2169325
WORKING HOURS

  • Monday10.00am - 7.00pm
  • Tuesday10.00am - 7.00pm
  • Wednesday10.00am - 7.00pm
  • Thursday10.00am - 7.00pm
  • FridayClosed
  • Saturday10.00am - 7.00pm
  • Sunday10.00am - 7.00pm
Select your currency
PKR Pakistani rupee
WhatsApp Us