Find Interview Questions for Top Companies
Ques:- what are Implode and Explode functions?
Asked In :-
Right Answer:
The `implode` function in PHP joins array elements into a single string using a specified separator, while the `explode` function splits a string into an array based on a specified delimiter.
Comments
Admin May 17, 2020

The implode() function takes an already existing array as
it's argument, and concatenates the contents of
each element in the array into a string.
where as explode() function performs reverse to implode()
function. It splits the string into items by a
delimiter, such as a dash, ampersand, space and places each
item into a new array.

Admin May 17, 2020

explode function:-it breaks a string into array.
<?php
$str="hello world.it's a beautiful day.":
print_r(explode(" ",$str):
?>
ans-ARRAY
[0]=>hello
[1]=>world.
[2]=>it's
[3]=>a
[4]=>beautiful
[5]=>day.
implode:-returns a string from elements of an array.
<?php
$arr=array('hello','world!',beautiful,'day!');
echo implode(" ",$arr);
?>
ans-hello world! beautiful day!

Ques:- What changes to done in PHP.ini file for file uploading?
Asked In :-
Right Answer:
To enable file uploading in PHP, you need to make the following changes in the `php.ini` file:

1. Set `file_uploads` to `On`:
```
file_uploads = On
```

2. Optionally, adjust the `upload_max_filesize` to set the maximum file size allowed for uploads:
```
upload_max_filesize = 2M
```

3. Optionally, adjust the `post_max_size` to ensure it is larger than `upload_max_filesize`:
```
post_max_size = 8M
```

4. Optionally, set `max_file_uploads` to limit the number of files that can be uploaded in one request:
```
max_file_uploads = 20
```
Comments
Admin May 17, 2020

post_max_size also should be greater than upload_max_filesize

Ques:- What is the default session time in PHP and how can I change it?
Asked In :-
Right Answer:
The default session time in PHP is 1440 seconds (24 minutes). You can change it by setting the `session.gc_maxlifetime` directive in the `php.ini` file or by using the `ini_set()` function in your script, like this: `ini_set('session.gc_maxlifetime', 3600);` for 1 hour.
Comments
Admin May 17, 2020

default session time 1440.
we can change it by
$garbaze="14400";
ini_set(session_gc_maxlifetime,$garbaze);

Admin May 17, 2020

default session time in PHP is 1440 seconds. if we want to
change the session time in php, then we have to change in
php.ini.

Ques:- How to use the COM components in PHP?
Asked In :-
Right Answer:
To use COM components in PHP, you can use the `COM` class. First, ensure that the `php_com_dotnet.dll` extension is enabled in your `php.ini` file. Then, you can create an instance of a COM object like this:

```php
$comObject = new COM("Your.Com.Component");
```

You can then call methods or access properties of the COM object using standard PHP syntax.
Comments
Admin May 17, 2020

Use Following Code :
<?php
$objCom = new COM(“AddNumber.math”);
$result = $objCom ->AddTwoNum(2,2);
echo $result;
?>

Admin May 17, 2020

<?php
dl(extension.dll); //as com
?>

Ques:- How many ways we can give the output to a browser?
Asked In :-
Right Answer:
There are several ways to give output to a browser in PHP:

1. **Echo** - Using the `echo` statement to output strings.
2. **Print** - Using the `print` statement to output strings.
3. **Print_r** - Using `print_r()` to output arrays and objects in a human-readable format.
4. **Var_dump** - Using `var_dump()` to output detailed information about variables, including type and value.
5. **HTML Tags** - Directly outputting HTML content within PHP code.
6. **JSON** - Using `json_encode()` to output JSON data.
7. **Headers** - Sending HTTP headers using `header()` function before outputting content.

These methods can be used individually or in combination to display content in a web browser.
Comments
Admin May 17, 2020

Use
1. print()
2. echo()
3. printf() functions to give the output to a browser.

Admin May 17, 2020

With the use of echo() and print() function we can give
output to a browser.

Ques:- What are the different methods of passing data or information between two calls of a web page? What are the advantages/disadvantages of these methods?
Asked In :-
Right Answer:
The different methods of passing data between two calls of a web page are:

1. **GET Method**:
- **Advantages**: Simple to use, data is visible in the URL, can be bookmarked.
- **Disadvantages**: Limited data size, not secure (sensitive data exposed), data is visible in the URL.

2. **POST Method**:
- **Advantages**: No size limitation, more secure than GET (data not visible in URL), suitable for sensitive data.
- **Disadvantages**: Cannot be bookmarked, data is not visible in the URL.

3. **Cookies**:
- **Advantages**: Persistent data storage, can track user sessions, data is sent with every request.
- **Disadvantages**: Limited size (typically 4KB), can be disabled by users, security concerns if not handled properly.

4. **Sessions**:
- **Advantages**: Secure storage on the server, can store large amounts of
Comments
Admin May 17, 2020

we are using get, post ,session, cookie method for passing
data. in get method it pass data through url. and post
passes data through hidden variable. and in session we
create session variable these variable store on server .
and cokkie same as session but cookie store at client
machine.

Admin May 17, 2020

we are using get, post ,session, cookie, request method for
passing
data. in get method it pass data through url. and post
passes data through hidden variable. and in session we
create session variable these variable store on client
machine and Only SESSION ID stores on server.
and cokkie same as session but cookie store at client
machine.
Request method is same as get method. we use request method
for sending variables using href in <a> tag, or in
Javascript using document.location.href .

Ques:- What are the different ways to login to a remote server? Explain the means, advantages and disadvantages?
Asked In :-
Right Answer:
1. **SSH (Secure Shell)**
- **Means**: Use SSH client (e.g., OpenSSH) to connect to the server.
- **Advantages**: Secure, encrypted communication; supports key-based authentication.
- **Disadvantages**: Requires SSH server setup; may be blocked by firewalls.

2. **FTP/SFTP (File Transfer Protocol/Secure File Transfer Protocol)**
- **Means**: Use FTP/SFTP client (e.g., FileZilla) to access files on the server.
- **Advantages**: Easy file transfer; SFTP is secure.
- **Disadvantages**: FTP is not secure; requires additional configuration for SFTP.

3. **Remote Desktop Protocol (RDP)**
- **Means**: Use RDP client (e.g., Microsoft Remote Desktop) to access Windows servers.
- **Advantages**: Full GUI access; easy to use for Windows environments.
Ques:- Create a PHP web script with the following attributes: on start, three HTML form elements are shown: an string input field, a checkbox field, a dropdown/pull down list with 5 elements and a submit button. On submission, the form should be redisplayed (while remaining all options/inputs as the user has selected/entered them). Additionally, the selections/inputs of the user should be displayed in text. Please solve this without the use of any external libraries.
Asked In :-
Right Answer:
```php
<?php
// Start the session to retain form data
session_start();

// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Store the input values in session variables
$_SESSION['inputString'] = $_POST['inputString'];
$_SESSION['checkbox'] = isset($_POST['checkbox']) ? 'Checked' : 'Unchecked';
$_SESSION['dropdown'] = $_POST['dropdown'];
}

// Retrieve the values for display
$inputString = isset($_SESSION['inputString']) ? $_SESSION['inputString'] : '';
$checkbox = isset($_SESSION['checkbox']) ? $_SESSION['checkbox'] : 'Unchecked';
$dropdown = isset($_SESSION['dropdown']) ? $_SESSION['dropdown'] : '';
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Example</title>
</head>
<body>
<form method="post" action
Comments
Admin May 17, 2020

This is the Script:
<?php
if (isset($_POST["submit"]))
{
$textBox = $_POST["textBox"];
$dropdown = $_POST["dropdown"];
$check = $_POST["check"];
echo "Form submitted.";
}
else
{
echo "Please submit form";
}
?>
<form name="frm" method="post" action="<?php
$_SERVER["PHP_SELF"]?>" >
<input type="text" name="textBox" value="<?php echo
$textBox ?>" /><br />
<input type="checkbox" name="check" value="1" <?php if
($check == "1") echo "checked" ?> /><br />
<select name="dropdown">
<option <?php if ($dropdown == "Pankaj") echo "selected";
?> >Pankaj</option>
<option <?php if ($dropdown == "Bisane") echo "selected";
?> >Bisane</option>
<option <?php if ($dropdown == "MCS") echo "selected"; ?>
>MCS</option>
</select><br /><br />
<input type="submit" name="submit" value= "Submit" /><br />
</from>

Ques:- What is MIME?
Asked In :-
Right Answer:
MIME stands for Multipurpose Internet Mail Extensions. It is a standard that indicates the nature and format of a document, file, or assortment of bytes, allowing email clients and web browsers to properly display or process the content.
Comments
Admin May 17, 2020

A .mim or .mme file is a file in the Multipurpose Internet
Mail Extension (MIME) format.
MIME is a specification for the format of non-text e-mail
attachments that allows the attachment to be sent over the
Internet. MIME allows your mail client or Web browser to
send and receive things like spreadsheets and audio, video
and graphics files via Internet mail.
MIME was defined in 1992 by the Internet Engineering Task
Force (IETF). The distinguishing characteristic of a MIME
message is the presence of the MIME headers. As long as your
mail recipients also have e-mail software that is MIME-
compliant (and most e-mail software is), you can swap files
containing attachments automatically.
Here are some tips for e-mail attachments:
You can use a utility like WinZip (PC) or StuffIt (Mac) to
compress a large file before you send. Most e-mail systems
will not accept messages that exceed a certain size.
It is a good idea to send attached photographs in the Joint
Photographic Experts Group (JPEG) format rather than the GIF
or TIFF formats. JPEG (.jpg) files use less space and
therefore upload faster.
AOL and some e-mail software uses .mme or .mim files as a
"wrapper" for mail that contains non-text attachments. Use
care when sending a MIME attachment to users of older
versions of AOL software, as the earlier versions do not
handle MIME very well. Send one attachment per e-mail. If
you are an AOL user, use the keyword (Ctrl+K) MIME to view
help about decoding MIME files.

Admin May 17, 2020

While using MIME email with PHP is a pretty fun process, the
bad news is that it can be quite challenging to implement,
particularly if you're not very familiar with its most
complex facets. There's also the possibility that you often
find yourself writing the same annoying code over and over
again, especially when you have to construct MIME email
modules within your applications.

Ques:- How can we know the number of days between two given dates using PHP?
Asked In :-
Right Answer:
You can find the number of days between two dates in PHP using the `DateTime` class. Here’s an example:

```php
$date1 = new DateTime("2023-01-01");
$date2 = new DateTime("2023-01-31");
$interval = $date1->diff($date2);
echo $interval->days; // Outputs: 30
```
Comments
Admin May 17, 2020

$date1 = date('Y-m-d');
$date2 = "2007-07-05";
$days = (strtotime($date1) - strtotime($date2)) / (60 * 60
* 24);
echo " No of $days difference";

Admin May 17, 2020

Something we must know about strtotime
(try putting up a date grater than 30 years)
yes it will give an unexpected output, because it uses, unix
timestamp, and thus doesnt treat a date greater than 30 yrs,
as a correct value.
Amazing but true

Ques:- What type of inheritance that PHP supports?
Asked In :-
Right Answer:
PHP supports single inheritance, meaning a class can inherit from only one parent class. However, it allows multiple interfaces to be implemented.
Comments
Admin May 17, 2020

PHP supports Multi-level inheritence.It wont support
multiple inheritence,but we can achieve multiple
inheritence through interfaces.

Admin May 17, 2020

PHP can support single,multilevel inheritance. And you can
use interfaces to achive multiple inheritace but not
directly multiple inheritance is allowed due to its
limitations

Ques:- WWhat is the functionality of md5 function in PHP?
Asked In :-
Right Answer:
The `md5` function in PHP generates a 32-character hexadecimal hash value from a given string, which is commonly used for data integrity checks and storing passwords securely.
Comments
Admin May 17, 2020

md5 means Messagedigest5 is an algorithem
converst the plain text to hipher text
mainly used in store the user passwords in database

Admin May 17, 2020

With the md5 function you can encrypt your text with 32
character hexadecimal string.
For Ex.
$str = 'apple';
echo md5($str);
this prints '1f3870be274f6c49b3e31a0c6728957f'

Ques:- What is the use of header() function in php?
Asked In :-
Right Answer:
The `header()` function in PHP is used to send raw HTTP headers to the client, allowing you to control the response sent to the browser, such as redirecting to another page or setting content type.
Ques:- How do you create subdomains using PHP?
Asked In :-
Right Answer:
To create subdomains using PHP, you typically need to configure your web server (like Apache or Nginx) to handle subdomains and then use PHP to manage the content. Here’s a basic approach:

1. **DNS Configuration**: Set up a wildcard DNS record (e.g., `*.example.com`) pointing to your server's IP address.

2. **Web Server Configuration**: Configure your web server to accept requests for subdomains. For Apache, you can use a VirtualHost with a ServerAlias for `*.example.com`.

3. **PHP Handling**: In your PHP script, you can access the subdomain using `$_SERVER['HTTP_HOST']` or `$_SERVER['SERVER_NAME']` and then parse it to determine the specific subdomain.

Example PHP code to get the subdomain:
```php
$host = $_SERVER['HTTP_HOST'];
$subdomain = explode('.', $host)[0]; // Assuming the format is subdomain.example.com
``
Ques:- What is the diffrence between Notify URL and Return URL?
Asked In :-
Right Answer:
Notify URL is used by the payment gateway to send transaction status updates to the merchant's server, while Return URL is where the user is redirected after completing the payment process.
Ques:- How to get the URL domain name in PHP?
Asked In :-
Right Answer:
You can get the URL domain name in PHP using the following code:

```php
$domain = parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST);
```

If you want to get the domain from a full URL, use:

```php
$domain = parse_url('http://example.com/path', PHP_URL_HOST);
```
Ques:- Which will execute faster on php POST or GET? Explain
Asked In :- secure meters,
Right Answer:
GET requests generally execute faster than POST requests because GET requests send data in the URL, which is simpler and requires less overhead than the body of a POST request. However, the difference in speed is usually negligible for most applications.
Ques:- What is the use of sprintf() function?
Asked In :-
Right Answer:
The `sprintf()` function in PHP is used to format a string according to a specified format and return the formatted string without outputting it.
Ques:- How do we know browser properties?
Asked In :-
Right Answer:
You can know browser properties using the `navigator` object in JavaScript. For example, `navigator.userAgent` provides information about the browser type and version.
Ques:- What is htaccess?
Asked In :-
Right Answer:
`.htaccess` is a configuration file used on web servers running Apache to manage server settings, such as URL redirection, access control, and custom error pages.


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