Find Interview Questions for Top Companies
Ques:- What are the differences between public, private, protected, static, transient, final and volatile?
Asked In :-
Right Answer:
- **public**: Accessible from anywhere.
- **private**: Accessible only within the class it is declared.
- **protected**: Accessible within the class and by subclasses.
- **static**: Belongs to the class rather than instances; shared across all instances.
- **transient**: Prevents serialization of a variable; not saved when the object is serialized.
- **final**: Cannot be overridden (for methods) or inherited (for classes); a final variable cannot be changed.
- **volatile**: Indicates that a variable's value may be changed by different threads; ensures visibility of changes across threads.
Comments
Admin May 17, 2020

Public : access anyware in script
Protected: access only same class and access inherited class
Private: access only in same class
Final: restrict overriding with child class

Admin May 17, 2020

in object by default all variables are presistent. so some
time we want to avoid that variables means we use transient
for that variable.

Ques:- What are the features and advantages of object-oriented programming?
Asked In :-
Right Answer:
The features of object-oriented programming (OOP) include:

1. **Encapsulation**: Bundling data and methods that operate on the data within one unit (class).
2. **Abstraction**: Hiding complex implementation details and showing only the essential features of an object.
3. **Inheritance**: Allowing a new class to inherit properties and methods from an existing class.
4. **Polymorphism**: Enabling objects to be treated as instances of their parent class, allowing for method overriding and overloading.

Advantages of OOP include:

1. **Reusability**: Code can be reused through inheritance and composition.
2. **Maintainability**: Easier to manage and update code due to modular structure.
3. **Scalability**: Facilitates the development of large systems by organizing code into manageable sections.
4. **Improved collaboration**: Multiple developers can work on different classes simultaneously.
Comments
Admin May 17, 2020

maintainability,flexibility,less code

Admin May 17, 2020

standardization , re-usability , flexibility , less code

Ques:- What are the differences between procedure-oriented languages and object-oriented languages?
Asked In :-
Right Answer:
1. **Paradigm**: Procedure-oriented languages focus on functions and procedures, while object-oriented languages focus on objects and classes.
2. **Data Handling**: Procedure-oriented languages separate data and functions, whereas object-oriented languages encapsulate data and functions together.
3. **Reusability**: Object-oriented languages promote code reusability through inheritance and polymorphism, while procedure-oriented languages do not have these features.
4. **Abstraction**: Object-oriented languages provide abstraction through classes, while procedure-oriented languages do not inherently support abstraction.
5. **State Management**: In object-oriented languages, objects maintain their state, while in procedure-oriented languages, state is managed through global or local variables.
Comments
Admin May 17, 2020

In procedural programming the main emphasis is on procedure
while in object oriented the data is important part. on the
same hand data is more secured in object oriented program.
-----------------------------------------------------------
Procedure Oriented Language:
---------------------------
PO Language is fully concentrates on
Procedures/functions/methods. It normally works as a
sequence of actions as seen in flowchart or in any
algorithm. It follows top-down approach. It totally focuses
on methods and not the data which is utilized by methods.
In PO languages if data is used by many methods then its
declared as global data but there is a problem if we do
that, what is that, if we forgot or by mistake if we
consume that data in some other method than it comes with
problem. Mostly these scenarios happen in large systems.
Example: COBOL, PASCAL, C, FORTRAN etc.
Object Oriented Language:
------------------------
OO concepts says it think about data and bind that data and
methods those are manipulating that data into one entity
known as object and then utilize that object into system.
Example: C++, Java, C#, VB.Net etc.
There are some fundamental concepts of OO Language which a
language has to follow to be a truly OO language.
• OBJECT
• CLASS
• ABSTRACTION
• ENCAPSULATION
• DATA HIDING / INFORMATION HIDING
• INHERITANCE
• POLYMORPHISM

Admin May 17, 2020

C employs top down approach which is an procedure oriented,
where as c++ employs bottom up approach which is an object
oriented language.

Ques:- What is the use of friend function?
Asked In :-
Right Answer:
A friend function in C++ is a function that is given access to the private and protected members of a class, allowing it to operate on the class's data even though it is not a member of that class.
Comments
Admin May 17, 2020

Sometimes a function is best shared among a number of
different classes. Such functions can be declared either as
member functions of one class or as global functions. In
either case they can be set to be friends of other classes,
by using a friend specifier in the class that is admitting
them. Such functions can use all attributes of the class
which names them as a friend, as if they were themselves
members of that class. A friend declaration is essentially a
prototype for a member function, but instead of requiring an
implementation with the name of that class
attached by the double colon syntax, a global function or
member function of another class provides the match.

Admin May 17, 2020

friend function can acces private member in class

Ques:- What are the reasons for selecting lamp (linux, apache, mysql, PHP) instead of combination of other software programmes, servers and operating systems?
Asked In :-
Right Answer:
LAMP is popular because it is open-source, cost-effective, and has a large community for support. It offers flexibility, stability, and ease of use, making it suitable for web development. Additionally, it allows developers to use familiar tools and technologies, ensuring quick deployment and scalability.
Comments
Admin May 17, 2020

All of those are open source resource and costs nothing.
Security of Linux is very more than windows. Apache is a
better server that IIS both in functionality and security.
MySQL is world most popular open source database. PHP is
more faster that asp or any other scripting languag.

Admin May 17, 2020

lamp for linux purpose.. and wamp for windows purpose.. and
php, mysql, apache these all are open source.

Ques:- How can we encrypt and decrypt a data present in a mysql table using mysql?
Asked In :-
Right Answer:
You can encrypt and decrypt data in a MySQL table using the `AES_ENCRYPT()` and `AES_DECRYPT()` functions.

To encrypt data:
```sql
INSERT INTO your_table (encrypted_column) VALUES (AES_ENCRYPT('your_data', 'your_secret_key'));
```

To decrypt data:
```sql
SELECT AES_DECRYPT(encrypted_column, 'your_secret_key') FROM your_table;
```
Comments
Admin May 17, 2020

using AES_ENCRYPT() and AES_DECRYPT().

Admin May 17, 2020

Using
AES_ENCRYPT() and AES_DECRYPT()

Ques:- Draw the architecture of Zend engine?
Asked In :-
Right Answer:
The architecture of the Zend Engine can be represented as follows:

1. **PHP Script**: The source code written in PHP.
2. **Lexer**: Converts the PHP script into tokens.
3. **Parser**: Transforms tokens into an abstract syntax tree (AST).
4. **Compiler**: Compiles the AST into opcode (Zend opcodes).
5. **Zend Engine**: Executes the opcodes using the Zend Virtual Machine (VM).
6. **Extensions**: Provides additional functionality through C extensions.
7. **Output**: The final output is sent to the web server or client.

This architecture allows for efficient execution and management of PHP scripts.
Comments
Admin May 17, 2020

The Zend Engine is the internal compiler and runtime engine
used by
PHP4. Developed by Zeev Suraski and Andi Gutmans, the Zend
Engine is an
abbreviation of their names. In the early days of PHP4, it
worked as
follows:
The PHP script was loaded by the Zend Engine and compiled
into Zend
opcode. Opcodes, short for operation codes, are low level binary
instructions. Then the opcode was executed and the HTML
generated sent
to the client. The opcode was flushed from memory after
execution.Today, there are a multitude of products and
techniques to help you
speed up this process.
In the following diagram, we show the how modern
PHP scripts work; all the shaded boxes are optional.
PHP Scripts are loaded into memory and compiled into Zend
opcodes.
(oops..i couldn't copy the images. is there any other way to
post them?)

Ques:- What are the current versions of apache, PHP, and mysql?
Asked In :-
Right Answer:
As of October 2023, the current versions are:

- Apache: 2.4.54
- PHP: 8.2.10
- MySQL: 8.0.33
Comments
Admin May 17, 2020

PHP -5.1.2
Mysql -5.1
Apache - 2
Wamp -1.7.3

Admin May 17, 2020

PHP: 7.0.4 / March 3, 2016
Apache: 2.4.18 December 14, 2015
MySQL: 5.6.26 / July 24, 2015

Ques:- Name the Functions in IMAP, POP3 AND LDAP?
Asked In :-
Right Answer:
**IMAP Functions:**
- imap_open()
- imap_close()
- imap_fetch_overview()
- imap_fetchbody()
- imap_search()
- imap_append()
- imap_delete()
- imap_expunge()

**POP3 Functions:**
- pop3_open()
- pop3_close()
- pop3_get()
- pop3_delete()
- pop3_stat()
- pop3_list()

**LDAP Functions:**
- ldap_connect()
- ldap_bind()
- ldap_search()
- ldap_add()
- ldap_modify()
- ldap_delete()
- ldap_unbind()
Comments
Admin May 17, 2020

IMAP:-( Internet Message Accese protocol) Port No is- 143
1.imap_list : Read the list of mailboxes
2. imap_open : Opens an IMAP stream to mailbox
3.after open the mail box one copy of the mail ll be a store
in server.
POP3 (Post Office Protocal) Port no-110
1.imap_list : Read the list of mailboxes
2.imap_open : Opens an IMAP stream to mailbox
3.After open the mail there ll be nothing in server.
LDAP:- (Light weight Directory Access protocol) port no-636
1. ldap_connect : This will connect to the ldap server with
the given login credentials.
2. ldap_search : By using this command we can search in ldap
records.
3.It is faster than other database like mysql,sql,oracle
4.It can write small amount of data but read becames faster.
5.Ex: outlook express

Admin May 17, 2020

Examples of IMAP Functions:
1. imap_list : Read the list of mailboxes
2. imap_open : Opens an IMAP stream to mailbox
Examples of LDAP Functions:
1. ldap_connect : This will connect to the ldap server with
the given login credentials.
2. ldap_search : By using this command we can search in ldap
records.

Ques:- Suppose your Zend engine supports the mode ?> Then how can u configure your PHP Zend engine to support mode ?
Asked In :-
Right Answer:
To configure your PHP Zend engine to support short open tags, you need to set the `short_open_tag` directive to `On` in your `php.ini` file:

```ini
short_open_tag = On
```
Comments
Admin May 17, 2020

Set this option in php.ini file to allow type of tags.
short_open_tag = On

Admin May 17, 2020

In the php.ini file you can change the value of
short_open_tag = on in to short_open_tag = off

Ques:- Shopping cart online validation i.e. how can we configure Paypal, etc.?
Asked In :-
Right Answer:
To configure PayPal for online shopping cart validation in PHP, follow these steps:

1. **Create a PayPal Account**: Sign up for a PayPal Business account.

2. **Get API Credentials**: Log in to your PayPal account and navigate to the Developer section to obtain your API credentials (Client ID and Secret).

3. **Integrate PayPal SDK**: Use the PayPal PHP SDK or REST API to integrate PayPal into your shopping cart. Install the SDK via Composer:
```bash
composer require paypal/rest-api-sdk-php
```

4. **Set Up Payment**: Create a payment request in your PHP code:
```php
$apiContext = new PayPalRestApiContext(
new PayPalAuthOAuthTokenCredential(
'YOUR_CLIENT_ID', // ClientID
'YOUR_CLIENT_SECRET' // ClientSecret
)
);

$payment = new PayPalApi
Ques:- What are the differences between require and include, include_once?
Asked In :-
Right Answer:
- **require**: Includes and evaluates the specified file. If the file is not found, it produces a fatal error and stops the script.
- **include**: Includes and evaluates the specified file. If the file is not found, it produces a warning but the script continues to execute.
- **include_once**: Similar to include, but it ensures that the file is included only once during the script execution, preventing redeclaration errors.
- **require_once**: Similar to require, but ensures the file is included only once, preventing redeclaration errors.
Comments
Admin May 17, 2020

include();--> include the file, but in case of file missing
throws a warning and continues execution of code of next line.
require();--> require also includes the file but in case of
file missing throws an fatal error and stop the execution of
the code of next line.
include_once();-->if same file was included first it will
not include the file another time.

Admin May 17, 2020

require - including a file/page ,if file doesn't exist,then
it gives error and doesn't execute.
include-including a file/page,if file doesn't exit,then it
gives warning and begin to execute.
include_once-including file/page, if it didn't been already
included,it includes else it won't.

Ques:- Can we use include (?abc.PHP?) two times in a PHP page ?makeit.PHP??
Asked In :-
Right Answer:
Yes, you can use `include('abc.php');` multiple times in a PHP page.
Comments
Admin May 17, 2020

yes we can use it.

Admin May 17, 2020

Yes we cab include the files two time in the PHP page.

Ques:- What are the different tables present in mysql, which type of table is generated when we are creating a table in the following syntax: create table employee(eno int(2),ename varchar(10)) ?
Asked In :-
Right Answer:
When you create a table using the syntax `create table employee(eno int(2), ename varchar(10))`, a **MyISAM** table is generated by default in MySQL, unless specified otherwise.
Comments
Admin May 17, 2020

Default type is MyISAM
Generates 3 files
1.frm
2.Myd
3.Myi
format files

Admin May 17, 2020

There are fives tables in MySQL
1 MyISAM
2 Heap
3 Merge
4 INNODB
5 ISAM
When we create a table in MySQL, MyISAM is created

Ques:- How can we extract string ?allinterview.com ? from a string ?http://info@allinterview.com? using regular expression of PHP?
Asked In :-
Right Answer:
You can extract the string "allinterview.com" from "http://info@allinterview.com" using the following PHP regular expression:

```php
$string = "http://info@allinterview.com";
preg_match('/@(.+)/', $string, $matches);
$extracted = $matches[1];
```

This will give you `$extracted` as "allinterview.com".
Ques:- In how many ways we can retrieve the date in the result set of mysql using PHP?
Asked In :-
Right Answer:
You can retrieve the date in the result set of MySQL using PHP in the following ways:

1. Using `mysqli_fetch_assoc()` to fetch results as an associative array.
2. Using `mysqli_fetch_array()` to fetch results as a numeric array or associative array.
3. Using `PDO::fetch()` to fetch results with PDO.
4. Using `PDO::fetchAll()` to retrieve all results at once with PDO.
5. Using `date()` function to format the date after fetching it from the database.

These methods allow you to access and manipulate date data retrieved from a MySQL database.
Comments
Admin May 17, 2020

4 ways
1. mysql_fetch_rows
2. mysql_fetch_object
3. mysql_fetch_assoc
4. mysql_fetch_array

Admin May 17, 2020

1. mysqli_fetch_rows
2. mysqli_fetch_object
3. mysqli_fetch_assoc
4. mysqli_fetch_array

Ques:- What is the difference between mysql_fetch_object and mysql_fetch_array?
Asked In :-
Right Answer:
`mysql_fetch_object` returns a result row as an object, while `mysql_fetch_array` returns a result row as an associative array, a numeric array, or both, depending on the specified parameter.
Comments
Admin May 17, 2020

mysql_fetch_object : will return the results from database
as objects. fields will be accessible like in objects
i.e $result->name,$result->cust_name
mysql_fetch_array : will return the results from database as
array. fields will be accessible like in objects
i.e $result[name],$result[cust_name]

Admin May 17, 2020

mysql_fetch_object : will return the results from database
as objects. fields will be accessible like in objects
i.e $result->name,$result->cust_name
mysql_fetch_array : will return the results from database as
an array.The array will be in in associative as well as
numeric manner.
i.e $result['column_name'] or $result[0].here '0'indicates
first column in table

Ques:- What are the differences between Get and post methods in form submitting, give the case where we can use get and we can use post methods?
Asked In :-
Right Answer:
The differences between GET and POST methods in form submission are:

1. **Data Visibility**:
- GET: Appends data to the URL, making it visible in the browser's address bar.
- POST: Sends data in the request body, keeping it hidden from the URL.

2. **Data Length**:
- GET: Limited to a small amount of data (around 2048 characters).
- POST: Can handle larger amounts of data.

3. **Caching**:
- GET: Requests can be cached by browsers.
- POST: Requests are not cached.

4. **Idempotency**:
- GET: Safe and idempotent; can be repeated without side effects.
- POST: Not idempotent; can cause changes on the server.

**Use Cases**:
- Use GET for retrieving data or when bookmarking is needed (e.g., search queries).
- Use POST for submitting sensitive data or when creating/updating resources (e.g
Comments
Admin May 17, 2020

get() method sends data in the form of url but post() method
will send as a data stream.
data transfered thru get() method is not secured whereas
post() method is safe and secured.
data sent thru get() method will be truncated but for post()
method there is no limitation on the amount of data being sent.

Ques:- Who is the father of PHP and explain the changes in PHP versions?
Asked In :-
Right Answer:
The father of PHP is Rasmus Lerdorf.

PHP has gone through several major versions:

- **PHP 1.0** (1995): The initial release, known as Personal Home Page Tools.
- **PHP 3.0** (1998): Introduced a new engine and more features, becoming a server-side scripting language.
- **PHP 4.0** (2000): Added support for sessions and improved performance with the Zend Engine.
- **PHP 5.0** (2004): Introduced object-oriented programming features and the PHP Data Objects (PDO) extension.
- **PHP 7.0** (2015): Significantly improved performance and introduced scalar type declarations and return type declarations.
- **PHP 8.0** (2020): Added Just In Time (JIT) compilation, union types, and attributes.

Each version brought enhancements in performance, security, and new features.
Comments
Admin May 17, 2020

Who know who is the father of php is any one knows that
please comment on this??????
if u ask who is the developer of the php then i tell RASMOUS
LEDORF.......

Admin May 17, 2020

Rasmus Ledorf is the father of PHP
PHP 3: Functionalities added.
PHP 4: Zend Engine added for code optimisation
PHP 5: Object oriented Programming concepts added.

Ques:- what do you mean by webserver’s document root?
Asked In :-
Comments
Admin May 17, 2020

Document Root is the webservers default directory from
which webserver serves the web documents according to
clients request. When we type website address in address
bar of browser. It displays the default document which we
have define with webserver configuration and it comes from
directory which we have defined as Document Root in web
server configuration.

Admin May 17, 2020

assume if we run like this
localhost/test/test.php
then the output is
c:xampphtdoc



The Core PHP category on takluu.com is designed for developers preparing for interviews that test their understanding of PHP fundamentals and server-side scripting. Core PHP forms the backbone of many web applications, enabling developers to create dynamic, interactive, and database-driven websites.

This section covers important topics such as PHP syntax, variables, data types, control structures, functions, arrays, sessions, cookies, file handling, and error handling. Additionally, it delves into working with forms, connecting to databases using MySQLi or PDO, and implementing security best practices like input validation and SQL injection prevention.

Interview questions often include practical coding problems, debugging scenarios, and explanations of how PHP interacts with the web server and databases. Understanding how to write clean, maintainable code and optimize PHP scripts for performance is also emphasized.

Candidates aspiring for roles like PHP Developer, Backend Developer, or Full Stack Developer will benefit from detailed tutorials, common interview questions, and real-world examples focused on Core PHP concepts.

At Takluu, we focus on building a strong foundation in Core PHP, enabling you to handle coding rounds confidently and develop scalable web solutions.

Whether you are a beginner or looking to refresh your PHP skills, this category provides comprehensive learning material and interview preparation tips to help you succeed.

AmbitionBox Logo

What makes Takluu valuable for interview preparation?

1 Lakh+
Companies
6 Lakh+
Interview Questions
50K+
Job Profiles
20K+
Users