Friday, September 27, 2013

PHP Interview questions Simple Answers - Part 1

With Simple Answers


Q: What is a PHP

PHP: Hypertext Preprocessor.

Q: What are the differences between Get and post methods.

GET:

    Parameters remain in browser history because they are part of the URL
    Can be bookmarked.
    GET method should not be used when sending passwords or other sensitive information.
    7607 character maximum size.
    Url example: page2.php?category=sport

POST:

    Parameters are not saved in browser history.
    Can not be bookmarked.
    POST method used when sending passwords or other sensitive information.
    8 Mb max size for the POST method.
    Url example: page2.php



What is the difference between an interface and an abstract class?
A: An interface defines a contract between an implementing class is and an object that calls the interface. An abstract class pre-defines certain behavior for classes that will extend it. To a certain degree this can also be considered a contract, since it guarantees certain methods to exist.

Q: Execute a PHP script using command line

run the PHP CLI (Command Line Interface) program and
provide the PHP script file name as the command line argument.

Q: What is htaccess?

htaccess files are configuration files of Apache Server which 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, and the directives apply to that directory, and all
subdirectories thereof.

Q: How we get IP address of client?

By using $_SERVER['REMOTE_ADDR'],$_SERVER['HTTP_REFERER'] etc.

Q: How can we convert asp pages to PHP pages?

using Javascript, onclick function,  call document.formname.submit()


Q: How to connect to a URL in PHP?

PHP provides a library called cURL.

CURL means Client URL Library


Q: How to store session data in a database

using session_set_save_handler()

Q: How can we create a database using PHP and MySQL?

We can create MySQL database with the use of
mysql_create_db("Database Name")

Q: How can we register the variables into a session?

$_SESSION['name'] = "test";



Q: How can we create a database

using mysql_create_db(“Name of your Database”)


Q: How can we extract one string from a main string using regular expression of PHP?

using preg_match

Q: How can we get the browser properties

with the help of $_SERVER['HTTP_USER_AGENT'] variable.

Q: Increase the execution time of a PHP script?

ini_set('max_execution_time', 300);

Q: encrypt the username and password using PHP

Mysql>SET PASSWORD=PASSWORD("Password");

No comments:

Post a Comment