Find Interview Questions for Top Companies
Ques:- Whats the difference between include() and require()?
Asked In :-
Right Answer:
The difference between `include()` and `require()` is that `include()` will emit a warning and continue the script if the file is not found, while `require()` will produce a fatal error and stop the script if the file is missing.
Comments
Admin May 17, 2020

You can insert the content of a file into a PHP file before
the server executes it, with the include() or require()
function.
The two functions are identical in every way, except how
they handle errors.
The include() function generates a warning but the script
will continue execution while the require() function
generates a fatal error and the script execution will stop
after the error.

Admin May 17, 2020

include() produces a Warning message where as require()
gives Fatal Error.

Ques:- what method is used to get a user’s IP address?
Asked In :-
Comments
Admin May 17, 2020

$_SERVER['REMOTE_ADDR']

Admin May 17, 2020

echo $_SERVER['REMOT_ADDR'];
it returns client IP Address

Ques:- Is it possible to connect to a Microsoft Access database without a DSN? If so, how??
Asked In :-
Right Answer:
Yes, it is possible to connect to a Microsoft Access database without a DSN by using a connection string in PHP with the `ODBC` extension. You can use the following code:

```php
$databasePath = 'C:\path\to\your\database.accdb';
$conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$databasePath;", '', '');
```

Make sure to replace `C:\path\to\your\database.accdb` with the actual path to your Access database file.
Comments
Admin May 17, 2020

Yes, we can
<?php
//Connect access database
$con=odbc_connect("DRIVER={Microsoft Access Driver
(*.mdb)}; DBQ=" . str_replace("/", "\", $_SERVER
["DOCUMENT_ROOT"]) . "foldernamedbname.mdb", "db_username"
, "db_password")or die("could'nt connect database");
if (!$con) {
die('Could not connect: ' . odbc_error());
}
?>

Admin May 17, 2020

ya its working niceley in my local system
still i have to check in server...
any way code is connecting database.

Ques:- How can you count number of parameters given in a URL by POST method?
Asked In :-
Right Answer:
You can count the number of parameters given in a URL by using the `$_POST` superglobal array in PHP. Use `count($_POST)` to get the number of parameters sent via the POST method.
Comments
Admin May 17, 2020

we can use count() function for it like
count($_POST) ;

Admin May 17, 2020

think count($_POST) will work.check it out.

Ques:- what is this error “Call to unsupported or undefined function mysql_connect();” and when you will get this?
Asked In :-
Comments
Admin May 17, 2020

This type of error will be displayed when mysql extension is
not enabled in your configuration file. This means,
mysql_connect is not supported.

Admin May 17, 2020

"Call to unsupported or undefined
function mysql_connect();"
these message is displayed when mysql dll file is not
specified in php.ini file or .dll which support mysql is
comment on php.ini file.

Ques:- Does it possible to compile php with mysql without having mysql sources?
Asked In :-
Right Answer:
Yes, it is possible to compile PHP with MySQL without having the MySQL sources, as PHP can use the MySQL client libraries instead.
Comments
Admin May 17, 2020

No. it is not possible

Admin May 17, 2020

Why it is not possible??

Ques:- What does PHP stand for?
Asked In :-
Right Answer:
PHP stands for "Hypertext Preprocessor."
Comments
Admin May 17, 2020

hyper text preprocessor

Admin May 17, 2020

PHP (recursive acronym for "PHP: Hypertext Preprocessor")

Ques:- Is it possible to get the screen resolution and like with php?
Asked In :-
Right Answer:
No, PHP cannot directly get the screen resolution because it runs on the server side and does not have access to client-side information. You would need to use JavaScript to obtain the screen resolution and then send it to the server if needed.
Comments
Admin May 17, 2020

Yes, it is possible to get screen resolution. But much more
easy with javascript:
Use => screen.width && screen.heigth

Ques:- How can you parse files that were not ending with .php by using Apache?
Asked In :-
Right Answer:
You can parse files that do not end with .php by using the `AddType` directive in the Apache configuration file (httpd.conf or .htaccess). For example, to parse `.html` files as PHP, add the following line:

```
AddType application/x-httpd-php .html
```

This will allow Apache to process `.html` files as PHP scripts.
Comments
Admin May 17, 2020

we need to change htpd.conf file for this ........have to
specify the extension which apache will parse as PHP file.

Ques:- what method is used to generate a random number?
Asked In :-
Right Answer:
The method used to generate a random number in PHP is `rand()`.
Comments
Admin May 17, 2020

use rand() or mt_rand()
example:rand() or rand(20,30);

Admin May 17, 2020

using rand() function we generate the random numbers.
example : $num="12345678";
$result=rand($num);
the $result gives the random numbers.

Ques:- How do you develop your own PHP extension ?
Asked In :-
Right Answer:
To develop your own PHP extension, follow these steps:

1. **Set Up Environment**: Ensure you have PHP source code and the necessary build tools installed.

2. **Create Extension Directory**: Create a directory for your extension, e.g., `my_extension`.

3. **Create config.m4**: Write a `config.m4` file to define your extension's configuration.

4. **Write C Code**: Create a C file (e.g., `my_extension.c`) that implements your extension's functions and defines the extension's entry points.

5. **Modify PHP.ini**: Update your `php.ini` to include your extension.

6. **Compile the Extension**: Use the `phpize` command to prepare the build environment, then run `./configure`, `make`, and `make install`.

7. **Test the Extension**: Verify that your extension is loaded in PHP by using `phpinfo()` or the `get_loaded_extensions()` function.

8.
Comments
Admin May 17, 2020

<?
print ".PHP";
?>

Admin May 17, 2020

<?
echo 'PHP';
?>
this file save as .php extention.

Ques:- can we use PGP with PHP?
Asked In :-
Right Answer:
Yes, we can use PGP with PHP by utilizing libraries such as GnuPG or OpenPGP.
Comments
Admin May 17, 2020

We would recomend using GnUPG not PGP, GnUPG can be used for
comercial sites without a license.
You will need shell access, i.e. telnet or SSH. SSH is more
secure. Also a linux machine and a copy of PGP installed on
your machine. You will also need to generate a key pair,
this consists of a public and private key. The public key is
uploaded to the server the private key is kept on your
machine. See the PGP help file for more information.
GnUPG must be installed, (Check with your server admin)
Access the shell as your user then do the following command :-
mkdir .gnupg
chmod 777 .gnupg
gpg --gen-key
use a dummy name and when it gets to the bit where it
generates the keys make sure the machine is doing I/O to get
the entropy.. ie. telnet in again and do a du / or something
its best to have this ready and just hit enter as you finish
the key creation
This creates a dummy key pair, this is not used but is needed.
This takes anything from a few seconds to a few minutes
depending on the speed of the server.
as the user, just ftp the ascii public key to the server.
This will be called something.asc. Upload it making sure its
ASCII not binary (See your FTP software help file)
then type ..
gpg --import file.asc
Then ..
gpg --list-keys
get the name of the new key that was uploaded, this will be
something like :-
pub 1024D/FA46F142 2000-11-03 Darren Casey
The next part is to set the permissions for the .gnupg
directory so the webserver can access the files. Type the
following commands :-
cd .gnupg
chmod 666 trustdb.gpg
chmod 604 secring.gpg
chmod 604 random_seed
chmod 644 pubring.gpg

Ques:- How do you format and output a number with leading zero’s?
Asked In :-
Comments
Admin May 17, 2020

$d=450;
$d = str_pad($d,6,0,0);
echo $d;
OUT PUT
000450

Admin May 17, 2020

Using sprinf("%04d",$num);
The above function will return a number of length 4.

Ques:- When you will get the error “Cannot add header information”?
Asked In :-
Comments
Admin May 17, 2020

Basicaly, any output to screen before an header function,
gives rise to this error.

Admin May 17, 2020

When page has html doctype on the starting of page.or some
echo statement on page when page is return or there is
header function on same page.

Ques:- How to install PHP with –mcrypt and –mhash?
Asked In :-
Ques:- How can you access a COM object from a PHP page?
Asked In :-
Right Answer:
You can access a COM object from a PHP page using the `new COM()` constructor. For example:

```php
$comObject = new COM("Your.ComObject.ClassName");
```

Make sure that the COM extension is enabled in your PHP configuration.
Comments
Admin May 17, 2020

By utilizing the com_load and the dotnet_load respectively
you can incorporate COM objects and .NET libraries into your
PHP code, thus anytime you see "library code" in a question,
make sure you remember these two functions.

Ques:- What is the difference between the functions UNLINKand UNSET?
Asked In :-
Right Answer:
`UNLINK` is used to delete a file from the filesystem, while `UNSET` is used to destroy a variable in PHP, removing its value and freeing up memory.
Comments
Admin May 17, 2020

Unset can be used for empty the value of variable or contents of file but unlink destroy file.

Admin May 17, 2020

unlink: is used to delete a file unset is used to destroy an eralier declared variable

Ques:- What are the different types of Errors in PHP?
Asked In :-
Right Answer:
The different types of errors in PHP are:

1. **Parse Errors**: Syntax errors in the code.
2. **Fatal Errors**: Critical errors that stop script execution.
3. **Warning Errors**: Non-fatal errors that do not stop script execution.
4. **Notice Errors**: Minor issues that indicate something may be wrong but do not affect execution.
Comments
Admin May 17, 2020

here are three basic types of runtime errors in PHP:
1. Notices: These are trivial, non-critical errors that PHP
encounters while executing a script - for example,
accessing a variable that has not yet been defined. By
default, such errors are not displayed to the user at all -
although you can change this default behaviour.
2. Warnings: These are more serious errors - for example,
attempting to include() a file which does not exist. By
default, these errors are displayed to the user, but they
do not result in script termination.
3. Fatal errors: These are critical errors - for example,
instantiating an object of a non-existent class, or calling
a non-existent function. These errors cause the immediate
termination of the script, and PHP?s default behaviour is
to display them to the user when they take place.

Admin May 17, 2020

As per above answer, PHP gives one more error message that
is :
Parse Error: When we make mistake in PHP code like, missing
semicolon or any unexpected symbol in code

Ques:- What types images that php supports?
Asked In :-
Right Answer:
PHP supports the following image types: JPEG, PNG, GIF, BMP, WebP, and SVG.
Comments
Admin May 17, 2020

imagetypes ? Return the image types supported by this PHP
build
This function returns a bit-field corresponding to the
image formats supported by the version of GD linked into
PHP. The following bits are returned, IMG_GIF | IMG_JPG |
IMG_PNG | IMG_WBMP | IMG_XPM
Example 1. imagetypes()

Ques:- Explain different types of errors in PHP (i.e. arguments in errorreporting function)?
Asked In :-
Right Answer:
In PHP, the `error_reporting()` function can take the following arguments to specify the types of errors to report:

1. `E_ALL` - All errors and warnings.
2. `E_ERROR` - Fatal run-time errors.
3. `E_WARNING` - Run-time warnings (non-fatal errors).
4. `E_PARSE` - Compile-time parse errors.
5. `E_NOTICE` - Run-time notices (suggestions for potential issues).
6. `E_STRICT` - Run-time notices for code that may not be compatible with future PHP versions.
7. `E_DEPRECATED` - Notices for deprecated features.
8. `E_USER_ERROR` - User-generated error messages.
9. `E_USER_WARNING` - User-generated warning messages.
10. `E_USER_NOTICE` - User-generated notices.

You can combine these constants using the bitwise OR operator (|) to report multiple types of errors.
Comments
Admin May 17, 2020

errors are classified into 3 types
1.fatal errors
2.parser errors
3.startup errors

Admin May 17, 2020

Its three types
1. Fatal error : this will stop the script.
2. Warning
3. Notice



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