Interview Quesions

What is PHP?
It stands for "Hypertext Preprocessor". It is an open source server-side scripting language that helps developer to create dynamic content with the help of database like mysql.
What is a Cookie?
A cookie is a small text file that created on your hard disk when your browser accesses a website that uses cookies. The stored information can be used by browser to rember all its features like logins, preferences, language settings, themes, among other common features.
How do you define a constant?
You can define a constant using the define() directive. define("VERSION",1.0);
What is the differences between require and include?
require() and include() are both the functions to include and evaluate the specified file. require() is identical to include() except upon failure, require() will produce a Fatal E_ERROR error and include() will emits a warning (E_WARNING) which allows the script to continue.
What the differences are between include and include_once?
include_once() includes and evaluates the specified file only once. So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.
What are the Different Types of Errors in PHP?
The following are the types of errors in PHP:

Notices: These are non-critical errors which PHP encounters while running a script. For example, a variable accessibility before it is declared.

Warnings: The are more serious errors. For example, using include()without the existence of the file.

Fatal Errors: These errors are critical errors. For example, creating an object of a non-existent class. These errors terminate the script’s execution immediately. These are intimated to the users.
What is the difference between mysql_fetch_object and mysql_fetch_array?
MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array.
How can we encrypt the username and password using PHP?
You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD(“Password”); OR You can use the MySQL PASSWORD () function to encrypt username and password. For example, INSERT into user (password …) VALUES (PASSWORD ($password?)) …);
How To Protect Special Characters in Query String?
If you want to include special characters like spaces in the query string, you need to protect them by applying the urlencode() translation function.
What are the differences between DROPS a table and TRUNCATE a table?
DROP TABLE table_name – This will delete the table and its data. TRUNCATE TABLE table_name – This will delete the data of the table, but not the table definition.
What are “GET” and “POST”?
GET and POST are methods used to send data to the server: With the GET method, the browser appends the data onto the URL. With the Post method, the data is sent as “standard input.”
How can we submit form without a submit button?
We can use a simple JavaScript code linked to an event trigger of any form field. In the JavaScript code, we can call the document.form.submit() function to submit the form.
How can we create a database using PHP and mysql?
We can create MySQL database with the use of mysql_create_db($databaseName) to create a database.
What is the maximum length of a table name, a database name, or a field name in MySQL?
Database name: 64 characters Table name: 64 characters Column name: 64 characters
How can we find the number of rows in a table using MySQL?
Use this for MySQL SELECT COUNT(*) FROM table_name;
What’s the default port for MySQL Server?
3306
How do you change a password for an existing user via mysqladmin?
mysqladmin -u root -p password “newpassword”
Use mysqldump to create a copy of the database?
mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql
What are some good ideas regarding user security in MySQL?
There is no user without a password. There is no user without a user name. There is no user whose Host column contains % (which here indicates that the user can log in from anywhere in the network or the Internet). There are as few users as possible (in the ideal case only root) who have unrestricted access.
Explain the difference between FLOAT, DOUBLE and REAL. ?
FLOATs store floating point numbers with 8 place accuracy and take up 4 bytes. DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes. REAL is a synonym of FLOAT for now.
What happens if a table has one column defined as TIMESTAMP?
That field gets the current timestamp whenever the row gets altered.

Popular posts from this blog

Detecting user's screen size and resolution

autoload class

MySql Slow Queries