Thursday, June 4, 2015

Codeigniter and PHP Interview questions

Top 200 PHP interview questions and answers are below

Questions : 1Who is the father of PHP ?
Answers : 1Rasmus Lerdorf is known as the father of PHP.
Questions : 2What is the difference between $name and $$name? 
Answers : 2$name is variable where as $$name is reference variable
like $name=sonia and $$name=singh so $sonia value is singh.
Questions : 3How can we submit a form without a submit button?
Answer : 3Java script submit() function is used for submit form without submit button
on click call document.formname.submit()
Questions : 4In how many ways we can retrieve the data in the result set of
MySQL using PHP?
Answer : 4We can do it by 4 Ways
1. mysql_fetch_row. , 2. mysql_fetch_array , 3. mysql_fetch_object
4. mysql_fetch_assoc
Questions : 5What is the difference between mysql_fetch_object and
mysql_fetch_array?
Answers : 5mysql_fetch_object() is similar tomysql_fetch_array(), with one difference -
an object is returned, instead of an array. Indirectly, that means that
you can only access the data by the field names, and not by their
offsets (numbers are illegal property names).
Questions : 6What are the differences between Get and post methods.
Answers : 6
There are some defference between GET and POST method
1. GET Method have some limit like only 2Kb data able to send for request
But in POST method unlimited data can we send
2. when we use GET method requested data show in url but
Not in POST method so POST method is good for send sensetive request
Questions : 7How can we extract string "pcds.co.in " from a string "http://info@pcds.co.in
using regular expression of PHP?
Answers : 7preg_match("/^http:\/\/.+@(.+)$/","http://info@pcds.co.in",$matches);
echo $matches[1];
Questions : 8How can we create a database using PHP and MySQL?
Answers : 8We can create MySQL database with the use of
mysql_create_db("Database Name")
Questions : 9What are the differences between require and include?
Answers : 9Both include and require used to include a file but when included file not found
Include send Warning where as Require send Fatal Error .
Questions : 10 Can we use include ("xyz.PHP") two times in a PHP page "index.PHP"?
Answers : 10  Yes we can use include("xyz.php") more than one time in any page. but it create a prob when xyz.php file contain some funtions declaration then error will come for already declared function in this file else not a prob like if you want to show same content two time in page then must incude it two time not a prob
Questions : 11  What are the different tables(Engine) present in MySQL, which one is default?
Answers : 11 Following tables (Storage Engine) we can create
1. MyISAM(The default storage engine IN MYSQL Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type. An .frm file stores the table format. The data file has an .MYD (MYData) extension. The index file has an .MYI (MYIndex) extension. )
2. InnoDB(InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data.)
3. Merge
4. Heap (MEMORY)(The MEMORY storage engine creates tables with contents that are stored in memory. Formerly, these were known as HEAP tables. MEMORY is the preferred term, although HEAP remains supported for backward compatibility. )
5. BDB (BerkeleyDB)(Sleepycat Software has provided MySQL with the Berkeley DB transactional storage engine. This storage engine typically is called BDB for short. BDB tables may have a greater chance of surviving crashes and are also capable of COMMIT and ROLLBACK operations on transactions)
6. EXAMPLE 
7. FEDERATED (It is a storage engine that accesses data in tables of remote databases rather than in local tables. )
8. ARCHIVE (The ARCHIVE storage engine is used for storing large amounts of data without indexes in a very small footprint. )
9. CSV (The CSV storage engine stores data in text files using comma-separated values format.)
10. BLACKHOLE (The BLACKHOLE storage engine acts as a "black hole" that accepts data but throws it away and does not store it. Retrievals always return an empty result)
Questions : 12 What is use of header() function in php ?
Answers : 12The header() function sends a raw HTTP header to a client.We can use herder()
function for redirection of pages. It is important to notice that header() must
be called before any actual output is seen..
Questions : 13How can I execute a PHP script using command line?
Answers : 13Just run the PHP CLI (Command Line Interface) program and
provide the PHP script file name as the command line argument.
Questions : 14Suppose your Zend engine supports the mode <? ?> Then how can u
configure your PHP Zend engine to support <?PHP ?> mode ?
Answers : 14In php.ini file:
set
short_open_tag=on
to make PHP support
Questions : 15Shopping cart online validation i.e. how can we configure Paypal,
etc.?
Answers : 15Nothing more we have to do only redirect to the payPal url after
submit all information needed by paypal like amount,adresss etc.
Questions : 16What is meant by nl2br()?
Answers : 16Inserts HTML line breaks (<BR />) before all newlines in a string.
Questions : 17What is htaccess? Why do we use this and Where?
Answers : 17.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.
Questions : 18How we get IP address of client, previous reference page etc ?
Answers : 18By using $_SERVER['REMOTE_ADDR'],$_SERVER['HTTP_REFERER'] etc.
Questions : 19What are the reasons for selecting lamp (Linux, apache, MySQL,
PHP) instead of combination of other software programs, servers and
operating systems?
Answers : 19All of those are open source resource. Security of Linux is very
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 language.
Questions : 20How can we encrypt and decrypt a data present in a MySQL table
using MySQL?
Answers : 20AES_ENCRYPT () and AES_DECRYPT ()
Questions : 21How can we encrypt the username and password using PHP?
Answers : 21The functions in this section perform encryption and decryption, and
compression and uncompression:
encryptiondecryption
AES_ENCRYT()AES_DECRYPT()
ENCODE()DECODE()
DES_ENCRYPT()DES_DECRYPT()
ENCRYPT()Not available
MD5()Not available
OLD_PASSWORD()Not available
PASSWORD()Not available
SHA() or SHA1()Not available
Not availableUNCOMPRESSED_LENGTH()
Questions : 22What are the features and advantages of object-oriented
programming?
Answers : 22One of the main advantages of OO programming is its ease of
modification; objects can easily be modified and added to a system there
by reducing maintenance costs. OO programming is also considered to be
better at modeling the real world than is procedural programming. It
allows for more complicated and flexible interactions. OO systems are
also easier for non-technical personnel to understand and easier for
them to participate in the maintenance and enhancement of a system
because it appeals to natural human cognition patterns.
For some systems, an OO approach can speed development time since many
objects are standard across systems and can be reused. Components that
manage dates, shipping, shopping carts, etc. can be purchased and easily
modified for a specific system
Questions : 23What are the differences between procedure-oriented languages and
object-oriented languages?
Answers : 23There are lot of difference between procedure language and object oriented like below
1>Procedure language easy for new developer but complex to understand whole software as compare to object oriented model
2>In Procedure language it is difficult to use design pattern mvc , Singleton pattern etc but in OOP you we able to develop design pattern
3>IN OOP language we able to ree use code like Inheritance ,polymorphism etc but this type of thing not available in procedure language on that our Fonda use COPY and PASTE .
Questions : 24What is the use of friend function?
Answers : 24Sometimes 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.
Questions : 25What are the differences between public, private, protected,
static, transient, final and volatile?
Answer : 25Public: Public declared items can be accessed everywhere.
Protected: Protected limits access to inherited and parent
classes (and to the class that defines the item).
Private: Private limits visibility only to the class that defines
the item.
Static: A static variable exists only in a local function scope,
but it does not lose its value when program execution leaves this scope.
Final: Final keyword prevents child classes from overriding a
method by prefixing the definition with final. If the class itself is
being defined final then it cannot be extended.
transient: A transient variable is a variable that may not
be serialized. 
volatile:
 a variable that might be concurrently modified by multiple
threads should be declared volatile. Variables declared to be volatile
will not be optimized by the compiler because their value can change at
any time.
Questions : 26What are the different types of errors in PHP?
Answer : 26Three are three types of errors: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, as you will
see, you can change this default behavior.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 behavior is to display them to the user
when they take place.
Questions : 27What is the functionality of the function strstr and stristr?
Answers : 27strstr Returns part of string from the first occurrence of needle(sub string that we finding out ) to the end of string.
$email= 'sonialouder@gmail.com';
$domain = strstr($email, '@');
echo $domain; // prints @gmail.com
here @ is the needle
stristr is case-insensitive means able not able to diffrenciate between a and A
Questions : 28What are the differences between PHP 3 and PHP 4 and PHP 5?
Answer : 28There are lot of difference among these three version of php
1>Php3 is oldest version after that php4 came and current version is php5 (php5.3) where php6 have to come
2>Difference mean oldest version have less functionality as compare to new one like php5 have all OOPs concept now where as php3 was pure procedural language constructive like C
In PHP5 1. Implementation of exceptions and exception handling
2. Type hinting which allows you to force the type of a specific argument
3. Overloading of methods through the __call function
4. Full constructors and destructors etc through a __constuctor and __destructor function
5. __autoload function for dynamically including certain include files depending on the class you are trying to create.
6 Finality : can now use the final keyword to indicate that a method cannot be overridden by a child. You can also declare an entire class as final which prevents it from having any children at all.
7 Interfaces & Abstract Classes
8 Passed by Reference :
9 An __clone method if you really want to duplicate an object
10 Numbers of Functions Deprecated in php 5.x like ereg,ereg_replace,magic_quotes_runtime, session_register,register_globals, split(), call_user_method() etc
Questions : 29How can we convert asp pages to PHP pages?
Answer : 29there are lots of tools available for asp to PHP conversion. you can
search Google for that. the best one is available athttp://asp2php.naken.cc./
Questions : 30What is the functionality of the function htmlentities?
Answer : 30Convert all applicable characters to HTML entities
This function is identical to htmlspecialchars() in all ways, except
with htmlentities(), all characters which have HTML character entity
equivalents are translated into these entities.
Questions : 31How can we get second of the current time using date function?
Answer : 31$second = date("s");
Questions : 32How can we convert the time zones using PHP?
Answer : 32By using date_default_timezone_get and 
date_default_timezone_set function on PHP 5.1.0

<?php
// Discover what 8am in Tokyo relates to on the East Coast of the US    

// Set the default timezone to Tokyo time:
date_default_timezone_set('Asia/Tokyo');    

// Now generate the timestamp for that particular timezone, on Jan 1st, 2000
$stamp = mktime(8, 0, 0, 1, 1, 2000);    

// Now set the timezone back to US/Eastern
date_default_timezone_set('US/Eastern');    

// Output the date in a standard format (RFC1123), this will print:
// Fri, 31 Dec 1999 18:00:00 EST
echo '<p>', date(DATE_RFC1123, $stamp) ,'</p>';?>
Questions : 33What is meant by urlencode and urldocode?
Answer : 33URLencode returns a string in which all non-alphanumeric characters
except -_. have been replaced with a percent (%)
sign followed by two hex digits and spaces encoded as plus (+)
signs. It is encoded the same way that the posted data from a WWW form
is encoded, that is the same way as in 
application/x-www-form-urlencoded
 media type.
urldecode decodes any %##
encoding in the given string.
Questions : 34What is the difference between the functions unlink and unset?
Answer : 34unlink() deletes the given file from the file system.
unset() makes a variable undefined.
Questions : 35How can we register the variables into a session?
Answer : 35$_SESSION['name'] = "sonia";
Questions : 36How can we get the properties (size, type, width, height) of an
image using PHP image functions?
Answer : 36To know the Image type use exif_imagetype () function
To know the Image size use getimagesize () function
To know the image width use imagesx () function
To know the image height use imagesy() function t
Questions : 37How can we get the browser properties using PHP?
Answer : 37By using 
$_SERVER['HTTP_USER_AGENT']
variable
Questions : 38What is the maximum size of a file that can be uploaded using PHP
and how can we change this?
Answer : 38By default the maximum size is 2MB. and we can change the following
setup at php.iniupload_max_filesize = 2M
Questions : 39How can we increase the execution time of a PHP script?
Answer : 39by changing the following setup at php.inimax_execution_time = 30
; Maximum execution time of each script, in seconds
Questions : 40How can we take a backup of a MySQL table and how can we restore
it. ?
Answer : 40To backup: BACKUP TABLE tbl_name[,tbl_name…] TO
'/path/to/backup/directory'
RESTORE TABLE tbl_name[,tbl_name…] FROM '/path/to/backup/directory'mysqldump: Dumping Table Structure and DataUtility to dump a database or a collection of database for backup or
for transferring the data to another SQL server (not necessarily a MySQL
server). The dump will contain SQL statements to create the table and/or
populate the table.
-t, –no-create-info
Don't write table creation information (the CREATE TABLE statement).
-d, –no-data
Don't write any row information for the table. This is very useful if
you just want to get a dump of the structure for a table!
Questions : 41How can we optimize or increase the speed of a MySQL select
query?
Answer : 41
  • first of all instead of using select * from table1, use select
    column1, column2, column3.. from table1
  • Look for the opportunity to introduce index in the table you are
    querying.
  • use limit keyword if you are looking for any specific number of
    rows from the result set.
Questions : 42How many ways can we get the value of current session id?
Answer : 42session_id() returns the session id for the current session.
Questions : 43How can we destroy the session, how can we unset the variable of
a session?
Answer : 43session_unregister — Unregister a global variable from the current
session
session_unset — Free all session variables
Questions : 44How can we set and destroy the cookie n php?
Answer : 44By using setcookie(name, value, expire, path, domain); function we can set the cookie in php ;
Set the cookies in past for destroy. like
setcookie("user", "sonia", time()+3600); for set the cookie
setcookie("user", "", time()-3600); for destroy or delete the cookies;
Questions : 45How many ways we can pass the variable through the navigation
between the pages?
Answer : 45
  • GET/QueryString
  • POST
Questions : 46What is the difference between ereg_replace() and eregi_replace()?
Answer : 46eregi_replace() function is identical to ereg_replace() except that
this ignores case distinction when matching alphabetic
characters.eregi_replace() function is identical to ereg_replace()
except that this ignores case distinction when matching alphabetic
characters.
Questions : 47What are the different functions in sorting an array?
Answer : 47Sort(), arsort(),
asort(), ksort(),
natsort(), natcasesort(),
rsort(), usort(),
array_multisort(), and
uksort().
Questions : 48How can we know the count/number of elements of an array?
Answer : 482 ways
a) sizeof($urarray) This function is an alias of count()
b) count($urarray)
Questions : 49what is session_set_save_handler in PHP?
Answer : 49session_set_save_handler() sets the user-level session storage functions which are used for storing and retrieving data associated with a session. This is most useful when a storage method other than those supplied by PHP sessions is preferred. i.e. Storing the session data in a local database.
Questions : 50How can I know that a variable is a number or not using a
JavaScript?
Answer : 50bool is_numeric ( mixed var)
Returns TRUE if var is a number or a numeric string, FALSE otherwise.or use isNaN(mixed var)The isNaN() function is used to check if a value is not a number.
Questions : 51List out some tools through which we can draw E-R diagrams for
mysql.
Answer : 51Case Studio
Smart Draw
Questions : 52How can I retrieve values from one database server and store them
in other database server using PHP?
Answer : 52we can always fetch from one database and rewrite to another. here
is a nice solution of it.$db1 = mysql_connect("host","user","pwd")
mysql_select_db("db1", $db1);
$res1 = mysql_query("query",$db1);$db2 = mysql_connect("host","user","pwd")
mysql_select_db("db2", $db2);
$res2 = mysql_query("query",$db2);At this point you can only fetch records from you previous ResultSet,
i.e $res1 – But you cannot execute new query in $db1, even if you
supply the link as because the link was overwritten by the new db.so at this point the following script will fail
$res3 = mysql_query("query",$db1); //this will failSo how to solve that? take a look below.
$db1 = mysql_connect("host","user","pwd")
mysql_select_db("db1", $db1);
$res1 = mysql_query("query",$db1);
$db2 = mysql_connect("host","user","pwd", true)
mysql_select_db("db2", $db2);
$res2 = mysql_query("query",$db2);
So mysql_connect has another optional boolean parameter which
indicates whether a link will be created or not. as we connect to the
$db2 with this optional parameter set to 'true', so both link will
remain live.
now the following query will execute successfully.
$res3 = mysql_query("query",$db1);
Questions : 53List out the predefined classes in PHP?
Answer : 53Directory
stdClass
__PHP_Incomplete_Class
exception
php_user_filter
Questions : 54How can I make a script that can be bi-language (supports
English, German)?
Answer : 54You can maintain two separate language file for each of the
language. all the labels are putted in both language files as variables
and assign those variables in the PHP source. on runtime choose the
required language option.
Questions : 55What are the difference between abstract class and interface?
Answer : 55Abstract class: abstract classes are the class where one or more
methods are abstract but not necessarily all method has to be abstract.
Abstract methods are the methods, which are declare in its class but not
define. The definition of those methods must be in its extending class.Interface: Interfaces are one type of class where all the methods are
abstract. That means all the methods only declared but not defined. All
the methods must be define by its implemented class.
Questions : 56How can we send mail using JavaScript?
Answer : 56JavaScript does not have any networking capabilities as it is
designed to work on client site. As a result we can not send mails using
JavaScript. But we can call the client side mail protocol mailto
via JavaScript to prompt for an email to send. this requires the client
to approve it.
Questions : 57How can we repair a MySQL table?
Answer : 57The syntex for repairing a MySQL table is
REPAIR TABLENAME, [TABLENAME, ], [Quick],[Extended]
This command will repair the table specified if the quick is given the
MySQL will do a repair of only the index tree if the extended is given
it will create index row by row
Questions : 58What are the advantages of stored procedures, triggers, indexes?
Answer : 58A stored procedure is a set of SQL commands that can be compiled and
stored in the server. Once this has been done, clients don't need to
keep re-issuing the entire query but can refer to the stored procedure.
This provides better overall performance because the query has to be
parsed only once, and less information needs to be sent between the
server and the client. You can also raise the conceptual level by having
libraries of functions in the server. However, stored procedures of
course do increase the load on the database server system, as more of
the work is done on the server side and less on the client (application)
side.Triggers will also be implemented. A trigger is effectively a type of
stored procedure, one that is invoked when a particular event occurs.
For example, you can install a stored procedure that is triggered each
time a record is deleted from a transaction table and that stored
procedure automatically deletes the corresponding customer from a
customer table when all his transactions are deleted.Indexes are used to find rows with specific column values quickly.
Without an index, MySQL must begin with the first row and then read
through the entire table to find the relevant rows. The larger the
table, the more this costs. If the table has an index for the columns in
question, MySQL can quickly determine the position to seek to in the
middle of the data file without having to look at all the data. If a
table has 1,000 rows, this is at least 100 times faster than reading
sequentially. If you need to access most of the rows, it is faster to
read sequentially, because this minimizes disk seeks.
Questions : 59What is the maximum length of a table name, database name, and
fieldname in MySQL?
Answer : 59The following table describes the maximum length for each type of
identifier.
IdentifierMaximum Length
(bytes)
Database64
Table64
Column64
Index64
Alias255
There are some restrictions on the characters that may appear in
identifiers:
Questions : 60How many values can the SET function of MySQL take?
Answer : 60MySQL set can take zero or more values but at the maximum it can
take 64 values
Questions : 61What are the other commands to know the structure of table using
MySQL commands except explain command?
Answer : 61describe Table-Name;
Questions : 62How many tables will create when we create table, what are they?
Answer : 62The '.frm' file stores the table definition.
The data file has a '.MYD' (MYData) extension.
The index file has a '.MYI' (MYIndex) extension,
Questions : 63What is the purpose of the following files having extensions 1) .frm
2) .myd 3) .myi? What do these files contain?
Answer : 63In MySql, the default table type is MyISAM.
Each MyISAM table is stored on disk in three files. The files have names
that begin with the table name and have an extension to indicate the
file type.
The '.frm' file stores the table definition.
The data file has a '.MYD' (MYData) extension.
The index file has a '.MYI' (MYIndex) extension,
Questions : 64What is maximum size of a database in MySQL?
Answer : 64If the operating system or filesystem places a limit on the number
of files in a directory, MySQL is bound by that constraint.The efficiency of the operating system in handling large numbers of
files in a directory can place a practical limit on the number of tables
in a database. If the time required to open a file in the directory
increases significantly as the number of files increases, database
performance can be adversely affected.
The amount of available disk space limits the number of tables.
MySQL 3.22 had a 4GB (4 gigabyte) limit on table size. With the MyISAM
storage engine in MySQL 3.23, the maximum table size was increased to
65536 terabytes (2567 – 1 bytes). With this larger allowed table size,
the maximum effective table size for MySQL databases is usually
determined by operating system constraints on file sizes, not by MySQL
internal limits.The InnoDB storage engine maintains InnoDB tables within a tablespace
that can be created from several files. This allows a table to exceed
the maximum individual file size. The tablespace can include raw disk
partitions, which allows extremely large tables. The maximum tablespace
size is 64TB.
The following table lists some examples of operating system file-size
limits. This is only a rough guide and is not intended to be definitive.
For the most up-to-date information, be sure to check the documentation
specific to your operating system.
Operating System File-size LimitLinux 2.2-Intel 32-bit 2GB (LFS: 4GB)
Linux 2.4+ (using ext3 filesystem) 4TB
Solaris 9/10 16TB
NetWare w/NSS filesystem 8TB
Win32 w/ FAT/FAT32 2GB/4GB
Win32 w/ NTFS 2TB (possibly larger)
MacOS X w/ HFS+ 2TB
Questions : 65Give the syntax of Grant and Revoke commands?
Answer : 65The generic syntax for grant is as following
> GRANT [rights] on [database/s] TO [username@hostname] IDENTIFIED BY
[password]
now rights can be
a) All privileges
b) combination of create, drop, select, insert, update and delete etc.We can grant rights on all databse by using *.* or some specific
database by database.* or a specific table by database.table_name
username@hotsname can be either username@localhost, username@hostname
and username@%
where hostname is any valid hostname and % represents any name, the *.*
any condition
password is simply the password of userThe generic syntax for revoke is as following
> REVOKE [rights] on [database/s] FROM [username@hostname]
now rights can be as explained above
a) All privileges
b) combination of create, drop, select, insert, update and delete etc.
username@hotsname can be either username@localhost, username@hostname
and username@%
where hostname is any valid hostname and % represents any name, the *.*
any condition
Questions : 66Explain Normalization concept?
Answer : 66The normalization process involves getting our data to conform to
three progressive normal forms, and a higher level of normalization
cannot be achieved until the previous levels have been achieved (there
are actually five normal forms, but the last two are mainly academic and
will not be discussed).First Normal FormThe First Normal Form (or 1NF) involves removal of redundant data
from horizontal rows. We want to ensure that there is no duplication of
data in a given row, and that every column stores the least amount of
information possible (making the field atomic).Second Normal FormWhere the First Normal Form deals with redundancy of data across a
horizontal row, Second Normal Form (or 2NF) deals with redundancy of
data in vertical columns. As stated earlier, the normal forms are
progressive, so to achieve Second Normal Form, your tables must already
be in First Normal Form.Third Normal Form I have a confession to make; I do not often use Third Normal Form. In
Third Normal Form we are looking for data in our tables that is not
fully dependant on the primary key, but dependant on another value in
the table
Questions : 67How can we find the number of rows in a table using MySQL?
Answer : 67Use this for mysql
>SELECT COUNT(*) FROM table_name;
Questions : 68How can we find the number of rows in a result set using PHP?
Answer : 68$result = mysql_query($sql, $db_link);
$num_rows = mysql_num_rows($result);
echo "$num_rows rows found";
Questions : 69How many ways we can we find the current date using MySQL?
Answer : 69SELECT CURDATE();
CURRENT_DATE() = CURDATE()
for time use
SELECT CURTIME();
CURRENT_TIME() = CURTIME()
Questions : 70What are the advantages and disadvantages of Cascading Style
Sheets?
Answer : 70External Style SheetsAdvantagesCan control styles for multiple documents at once. Classes can be
created for use on multiple HTML element types in many documents.
Selector and grouping methods can be used to apply styles under complex
contextsDisadvantagesAn extra download is required to import style information for each
document The rendering of the document may be delayed until the external
style sheet is loaded Becomes slightly unwieldy for small quantities of
style definitionsEmbedded Style Sheets Advantages
Classes can be created for use on multiple tag types in the document.
Selector and grouping methods can be used to apply styles under complex
contexts. No additional downloads necessary to receive style information
Disadvantages
This method can not control styles for multiple documents at once
Inline Styles
Advantages
Useful for small quantities of style definitions. Can override other
style specification methods at the local level so only exceptions need
to be listed in conjunction with other style methods
Disadvantages
Does not distance style information from content (a main goal of
SGML/HTML). Can not control styles for multiple documents at once.
Author can not create or control classes of elements to control multiple
element types within the document. Selector grouping methods can not be
used to create complex element addressing scenarios
Questions : 71What type of inheritance that PHP supports?
Answer : 71In PHP an extended class is always dependent on a single base class,
that is, multiple inheritance is not supported. Classes are extended
using the keyword 'extends'.
Questions : 72What is the difference between Primary Key and
Unique key?
Answer : 72Primary Key: A column in a table whose values uniquely identify the
rows in the table. A primary key value cannot be NULL. Unique Key: Unique Keys are used to uniquely identify each row in the
table. There can be one and only one row for each unique key value. So
NULL can be a unique key.There can be only one primary key for a table but there can be more
than one unique for a table.

Question : 73
what is garbage collection? default time ? refresh time?
Answer : 73Garbage Collection is an automated part of PHP , If the Garbage Collection process runs, it then analyzes any files in the /tmp for any session files that have not been accessed in a certain amount of time and physically deletes them. Garbage Collection process only runs in the default session save directory, which is /tmp. If you opt to save your sessions in a different directory, the Garbage Collection process will ignore it. the Garbage Collection process does not differentiate between which sessions belong to whom when run. This is especially important note on shared web servers. If the process is run, it deletes ALL files that have not been accessed in the directory. There are 3 PHP.ini variables, which deal with the garbage collector: PHP ini value name default session.gc_maxlifetime 1440 seconds or 24 minutes session.gc_probability 1 session.gc_divisor 100
Questions : 74What are the advantages/disadvantages of MySQL and PHP?
Answer : 74Both of them are open source software (so free of cost), support
cross platform. php is faster then ASP and JSP.
Questions : 75What is the difference between GROUP BY and ORDER BY in Sql?
Answer : 75ORDER BY [col1],[col2],…,[coln]; Tels DBMS according to what columns
it should sort the result. If two rows will hawe the same value in col1
it will try to sort them according to col2 and so on.GROUP BY
[col1],[col2],…,[coln]; Tels DBMS to group results with same value of
column col1. You can use COUNT(col1), SUM(col1), AVG(col1) with it, if
you want to count all items in group, sum all values or view average
Questions : 76What is the difference between char and varchar data types?
Answer : 76Set char to occupy n bytes and it will take n bytes even if u r
storing a value of n-m bytes
Set varchar to occupy n bytes and it will take only the required space
and will not use the n bytes
eg. name char(15) will waste 10 bytes if we store 'romharshan', if each char
takes a byte
eg. name varchar(15) will just use 5 bytes if we store 'romharshan', if each
char takes a byte. rest 10 bytes will be free.
Questions : 77What is the functionality of md5 function in PHP?
Answer : 77Calculate the md5 hash of a string. The hash is a 32-character
hexadecimal number. I use it to generate keys which I use to identify
users etc. If I add random no techniques to it the md5 generated now
will be totally different for the same string I am using.
Questions : 78How can I load data from a text file into a table?
Answer : 78you can use LOAD DATA INFILE file_name; syntax to load data
from a text file. but you have to make sure thata) data is delimited
b) columns and data matched correctly
Questions : 79How can we know the number of days between two given dates using
MySQL?
Answer : 79SELECT DATEDIFF("2007-03-07","2005-01-01");
Questions : 80How can we know the number of days between two given dates using PHP?
Answer : 80$date1 = date("Y-m-d");
$date2 = "2006-08-15";
$days = (strtotime($date1) - strtotime($date2)) / (60 * 60 * 24);
Questions : 81How we load all classes that placed in different directory in one PHP File , means how to do auto load classes
Answer : 81

by using spl_autoload_register('autoloader::funtion');

Like below

class autoloader

{

public static function moduleautoloader($class)

{

$path = $_SERVER['DOCUMENT_ROOT'] . "/modules/{$class}.php";

if (is_readable($path)) require $path;

}

public static function daoautoloader($class)

{

$path = $_SERVER['DOCUMENT_ROOT'] . "/dataobjects/{$class}.php";

if (is_readable($path)) require $path;

}

public static function includesautoloader($class)

{

$path = $_SERVER['DOCUMENT_ROOT'] . "/includes/{$class}.php";

if (is_readable($path)) require $path;

}

}

spl_autoload_register('autoloader::includesautoloader');

spl_autoload_register('autoloader::daoautoloader');

spl_autoload_register('autoloader::moduleautoloader');
Questions : 82How many types of Inheritances used in PHP and how we achieve it
Answer : 82As far PHP concern it only support single Inheritance in scripting.
we can also use interface to achieve multiple inheritance.
Questions : 83PHP how to know user has read the email?
Answers : 83Using Disposition-Notification-To: in mailheader we can get read receipt.
Add the possibility to define a read receipt when sending an email.
It̢۪s quite straightforward, just edit email.php, and add this at vars definitions:
var $readReceipt = null;
And then, at ‘createHeader’ function add:
if (!empty($this->readReceipt)) {
$this->__header .= ‘Disposition-Notification-To: ‘ . $this->__formatAddress($this->readReceipt) . $this->_newLine;
}
Questions : 84What are default session time and path?
Answers : 84default session time in PHP is 1440 seconds or 24 minutes
Default session save path id temporary folder /tmp
Questions : 85how to track user logged out or not? when user is idle ?
Answers : 85By checking the session variable exist or not while loading th page. As the session will exist longer as till browser closes. The default behaviour for sessions is to keep a session open indefinitely and only to expire a session when the browser is closed. This behaviour can be changed in the php.ini file by altering the line session.cookie_lifetime = 0 to a value in seconds. If you wanted the session to finish in 5 minutes you would set this to session.cookie_lifetime = 300 and restart your httpd server.
Questions : 86how to track no of user logged in ?
Answers : 86whenever a user logs in track the IP, userID etc..and store it in a DB with a active flag while log out or sesion expire make it inactive. At any time by counting the no: of active records we can get the no: of visitors.
Questions : 87in PHP for pdf which library used?
Answers : 87The PDF functions in PHP can create PDF files using the PDFlib library With version 6, PDFlib offers an object-oriented API for PHP 5 in addition to the function-oriented API for PHP 4. There is also the » Panda module. FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs. FPDF requires no extension (except zlib to activate compression and GD for GIF support) and works with PHP4 and PHP5.
Questions : 88for image work which library?
Answers : 88we will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with.
Questions : 89what is design pattern? singleton pattern?
Answers : 89A design pattern is a general reusable solution to a commonly occurring problem in software design.
The Singleton design pattern allows many parts of a program to share a single resource without having to work out the details of the sharing themselves.
Questions : 90what are magic methods?
Answers : 90Magic methods are the members functions that is available to all the instance of class Magic methods always starts with "__". Eg. __construct All magic methods needs to be declared as public To use magic method they should be defined within the class or program scope Various Magic Methods used in PHP 5 are: __construct() __destruct() __set() __get() __call() __toString() __sleep() __wakeup() __isset() __unset() __autoload() __clone()
Questions : 91what is magic quotes?
Answers : 91Magic Quotes is a process that automagically escapes ncoming data to the PHP script. It̢۪s preferred to code with magic quotes off and to instead escape the data at runtime, as needed. This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.
Questions : 92what is cross site scripting? SQL injection?
Answers : 92Cross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications which allow code injection by malicious web users into the web pages viewed by other users. Examples of such code include HTML code and client-side scripts. SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed
Questions : 93what is URL rewriting?
Answers : 93Using URL rewriting we can convert dynamic URl to static URL Static URLs are known to be better than Dynamic URLs because of a number of reasons 1. Static URLs typically Rank better in Search Engines. 2. Search Engines are known to index the content of dynamic pages a lot slower compared to static pages. 3. Static URLs are always more friendlier looking to the End Users. along with this we can use URL rewriting in adding variables [cookies] to the URL to handle the sessions.
Questions : 94what is the major php security hole? how to avoid?
Answers : 941. Never include, require, or otherwise open a file with a filename based on user input, without thoroughly checking it first.
2. Be careful with eval() Placing user-inputted values into the eval() function can be extremely dangerous. You essentially give the malicious user the ability to execute any command he or she wishes!
3. Be careful when using register_globals = ON It was originally designed to make programming in PHP easier (and that it did), but misuse of it often led to security holes
4. Never run unescaped queries
5. For protected areas, use sessions or validate the login every time.
6. If you don̢۪t want the file contents to be seen, give the file a .php extension.
Questions : 95whether PHP supports Microsoft SQL server ?
Answers : 95The SQL Server Driver for PHP v1.0 is designed to enable reliable, scalable integration with SQL Server for PHP applications deployed on the Windows platform. The Driver for PHP is a PHP 5 extension that allows the reading and writing of SQL Server data from within PHP scripts. using MSSQL or ODBC modules we can access Microsoft SQL server.
Questions : 96what is MVC? why its been used?
Answers : 96Model-view-controller (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other. In MVC, the model represents the information (the data) of the application; the view corresponds to elements of the user interface such as text, checkbox items, and so forth; and the controller manages the communication of data and the business rules used to manipulate the data to and from the model. WHY ITS NEEDED IS 1 Modular separation of function 2 Easier to maintain 3 View-Controller separation means:
A — Tweaking design (HTML) without altering code B — Web design staff can modify UI without understanding code
Questions : 97what is framework? how it works? what is advantage?
Answers : 97In general, a framework is a real or conceptual structure intended to serve as a support or guide for the building of something that expands the structure into something useful. Advantages : Consistent Programming Model Direct Support for Security Simplified Development Efforts Easy Application Deployment and Maintenance
Questions : 98what is CURL?
Answers : 98CURL means Client URL Library
curl is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS and FILE. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos…), file transfer resume, proxy tunneling and a busload of other useful tricks.
CURL allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP̢۪s ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.
Questions : 99what is PDO ?
Answers : 99The PDO ( PHP Data Objects ) extension defines a lightweight, consistent interface for accessing databases in PHP. if you are using the PDO API, you could switch the database server you used, from say PgSQL to MySQL, and only need to make minor changes to your PHP code.
While PDO has its advantages, such as a clean, simple, portable API but its maindisadvantage is that it doesn't allow you to use all of the advanced features that are available in the latest versions of MySQL server. For example, PDO does not allow you to use MySQL's support for Multiple Statements.
Just need to use below code for connect mysql using PDO
try {
$dbh = new PDO("mysql:host=$hostname;dbname=databasename", $username, $password);
$sql = "SELECT * FROM employee";
foreach ($dbh->query($sql) as $row)
{
print $row['employee_name'] .' - '. $row['employee_age'] ;
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
Questions : 100What is PHP's mysqli Extension?
Answers : 100The mysqli extension, or as it is sometimes known, the MySQL improved extension, was developed to take advantage of new features found in MySQL systems versions 4.1.3 and newer. The mysqli extension is included with PHP versions 5 and later.
The mysqli extension has a number of benefits, the key enhancements over the mysql extension being:
=>Object-oriented interface
=>Support for Prepared Statements
=>Support for Multiple Statements
=>Support for Transactions
=>Enhanced debugging capabilities
=>Embedded server support



Versions
-------------
Web developer suite 2.0
Apache server 2.2.6
Php 5.2.5
Mysql 5.0.45


Web application
-----------------
Joomla 1.0.13
Drupal 5.3.0
WordPress 2.3.1
phpBB2 2.0.22

101. what is difference between <? ?>(short tag) and <?php ?>(full tag).
102. What does a special set of tags <?= and ?> do in PHP?

ans- The output is displayed directly to the browser.It works like echo or print function.

103. what is difference between echo and print?

ans- print returns the value in true or false, where as echo doesnot return anything.

104. what is difference between explode implode?

ans-explode function:-it breaks a string into array.
<?php
$str="hello world.it's a beautiful day.":
print_r(explode(" ",$str):// space between two double quotes should be there otherwise it shows Warning: explode() [function.explode]: Empty delimiter in D:\www\vhosts\localhost\test\setupTest.php on line 29
?>
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!

105.Will comparison of string "10" and integer 11 work in PHP?

ans-Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.

106. how many types array are there in php?

ans- There are two types of array- a) numerical or index array b) associative array
    In numerical or index array the indexer,which is used to determine the position of a stored data (also known as key) is an integer.

    Where as in case of associative array the indexer or key which is used to reffered the data element is a string.

107. what is terinary opertion in php?

ans- It is called the ternary operator because it takes three operands - a condition, a result for true, and a result for false.

                    OR

Expression preceding the ? is evaluated, if it’s true, then the expression preceding    the : is executed, otherwise, the expression following : is executed.

    <?php
            $agestr = ($age < 18) ? 'child' : 'adult';
    ?>

108. explain two types of arraay sort.

ans-sort()->sort the array value alphabetically, but not maintaining the index.
    asort()->sort the array value alphabetically, and also maintaining the index.
    arsort()->sort the array value alphabetically in reverse order and also maintaining the index.

    ksort()->sort the array according to key.
    krsort()->sort the array according to key in the reverse order.

109. what is difference between strstr and stristr?

strstr-finds the first occurence of a string inside another
string (case-sensitive)
examle: <?php
$email = 'arvindpippal@gmail.com';
$domain = strstr($email, '@');
echo $domain;
?>
output: @gmail.com


stristr-finds the first occurence of a string inside
another string (case-insensitive)

110.what is substr()?

ans-substr() returns the portion of string specified by the start and length parameters.
syntax:- string substr ( string string, int start [, int length] )

111.Can u change localhost name in ur localsystem?

ans- yes, inside
    C:\Windows\System32\drivers\etc\hosts

112.how can u know size of array?

ans-The sizeof() function counts the elements of an array, or the properties of an object.

This function is an alias of the count() function.
$a = array(1,2,2,
    array(1,1));
    echo sizeof($a);// 4
    echo sizeof($a[1]);// 1
        echo sizeof($a[3]);// 2

113.Number of argument in a function,How can u know?

ans-func_num_args() function returns the number of parameters passed in.

114.what is a session and how can u destroy it?

ans-A PHP session allowing you to store user information on the server for later use (i.e. username, shopping items, etc). However, session information is temporary and will be deleted after the user has left the website. If you need a permanent storage you may want to store the data in a database.

    we are using session_unset()(deprecated) or session_destroy() to destroy the session. session_unset() free the all session variables,but session continues whereas session_destroy() destroys the session.

115.what is a cookies and how can u destroy it?

ans-. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too.

    The setcookie() function is used to set a cookie.
    <?php
    $expire=time()+60*60*24*30;
    setcookie("user", "Alex Porter", $expire);
    ?>

The PHP $_COOKIE variable is used to retrieve a cookie value.

    <?php
    // Print a cookie
    echo $_COOKIE["user"];

    // A way to view all cookies
    print_r($_COOKIE);
    ?>
When deleting a cookie you should assure that the expiration date is in the past.
    <?php
    // set the expiration date to one hour ago
    setcookie("user", "", time()-3600);
    ?>

116. how can u get current date and time?

ans- date('r');

117. how can u upload a image?

ans- we can upload a file by using the function move_uploaded_method() function.
18. what is difference between get and post?

ans-GET:- get method is default method.
    un secure way as data send through the url.
    we can send limited amount of data as url supports 255 characters.

    POST:- not a default method, we have to mention it explicitly.
    its a secure way as data send through the body part.
    we can send unlimited amount of data.
   
119. How can u et ip address of asystem?

ans- $_SERVER['SERVER_ADDR'];

     $_SERVER['REMOTE_ADDR'];

120. What is magic function and what are they?
121. What is Isset()?

ans-isset() determines whether a certain variable has already been declared by PHP. It returns a boolean value true if the variable has already been set, and false otherwise, or if the variable is set to the value NULL.

122. How can you submit a form without using submit buttom?

ans-Using javascript we can submit a form without using submmit button.

                    OR

If you don’t want to use the Submit button to submit a form, you can use normal hyper links to submit a form. But you need to use some JavaScript code in the URL of the link. For example:

<a href=”javascript: document.myform.submit();”>Submit Me</a>

123. what is difference between require() and require_once()?

ans-require() includes and evaluates a specific file while require_once() does that only if it has not been included before (on the same page).

124. what is difference between include() and include_once()?

ans-include() includes and evaluates a specific file while include_once() does that only if it has not been included before (on the same page).

125. what is difference between include() and require()?

ans- It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.

126. What is the difference between ereg_replace() and eregi_replace()?

ans-eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.

127. what is oops?

ans-One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real world than is procedural programming. It allows for more complicated and flexible interactions. OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition patterns. For some systems, an OO approach can speed development time since many objects are standard across systems and can be reused. Components that manage dates, shipping, shopping carts, etc. can be purchased and easily modified for a specific system.

128. What in inheritance and how many types of inheritance are there in php?

129. What in methodoverloading and polymerphism?
130. What is methodoverriding?
131. What is method overloading and over riding?
132. What is Php encapsulation?
133. What is abstarct method and abstarct class?
134. What is final method and final class?
135. What is Super concepts?
136. What is constructor and destructor?
137. what are the access specifier?

ans-The visibility of a property or method can be defined by prefixing the declaration with the keywords public, protected or private. Class members declared public can be accessed everywhere. Members declared protected can be accessed only within the class itself and by inherited and parent classes. Members declared as private may only be accessed by the class that defines the member.


138. What is 'This' key word?
139. what is coersion?
140. What is interface?
141. What is Exception handling?
142. waht is wrapper calss?
143. Give an example of Foreach;
144. what is split();?

ans- split is a function used for split the string by regular expression.

     split(":",$string);
145. What is abstraction in php?
146. function to display money separator by comma?
147. How can we send mail using JavaScript?

ans-No. There is no way to send emails directly using JavaScript.

But you can use JavaScript to execute a client side email program send the email using the “mailto” code. Here is an example:

{xtypo_code}
function myfunction(form)
{
   tdata=document.myform.tbox1.value;
   location=”mailto: mailid@domain.com?subject=…”;
   return true;
}
{/xtypo_code}

148.What is the difference between the functions unlink and unset?

ans-unlink() is a function for file system handling. It will simply delete the file in context.

unset() is a function for variable management. It will make a variable undefined.

149. what is difference between split() and explode()?

ans- split()-split the string by regular expression.
    split(":",$string);
     explode()-split the string by string.
    explode("",$string);
150. How can you get browser informaion in php?
151. what is difference between sinle qoute and double qoute?
152. what is role of == and === ,when we compare array?
153. what is CURL and its functionality?
154. what is MIME?

ans-MIME is Multipurpose Internet Mail Extensions is an Internet standard for the format of e-mail. However browsers also uses MIME standard to transmit files. MIME has a header which is added to a beginning of the data. When browser sees such header it shows the data as it would be a file (for example image)

Some examples of MIME types:

audio/x-ms-wmp
image/png
aplication/x-shockwave-flash

                        OR

Multipurpose Internet Mail Extensions.
WWW’s ability to recognize and handle files of different types is largely dependent on the use of the MIME (Multipurpose Internet Mail Extensions) standard. The standard provides for a system of registration of file types with information about the applications needed to process them. This information is incorporated into Web server and browser software, and enables the automatic recognition and display of registered file types. …

155. what is difference between drop table and truncate table?

ans-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.

156. what is difference between unset and unlink?
157. what is difference between __sleep and __wakeup()?

ans-- __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.

158. what is difference between htmlenties and htmlspecialcharacter()?

ans- htmlspecialchars only takes care of <, >, single quote ‘, double quote ” and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML.

159. Whar are the errors in php?

ans-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 behavior.

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 behavior is to display them to the user when they take place.

Internally, these variations are represented by twelve different error types

160. Is object of a class pass by a refference?

ans- Everything is passed by value.

161. What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?

ans-mysql_fetch_array – Fetch a result row as an associative array and a numeric array.

mysql_fetch_object – Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows

mysql_fetch_row() – Fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

162. How can you know value of a current session id?

ans-session_id();

163. How can you find difference between two dates?
164. how can u encrypt user name or passwors in php?

ans-using md5() we can encrypt username or password field in php.

165. How many way you can get a date from mysql?

ans-SELECT CURDATE();
SELECT CURRENT_DATE();
SELECT CURTIME();
SELECT CURRENT_TIME();

166. what is mysql engines and what are they?
167. what is difference between myisam and innodb?
168. what are the joins in mysql and what are they?

ans-Different types of joins are ----

    1.JOIN(Inner Join): Return rows when there is at least one match in both tables
    2.LEFT JOIN: Return all rows from the left table, even if there are no matches in the right table
    3.RIGHT JOIN: Return all rows from the right table, even if there are no matches in the left table
    4.FULL JOIN: Return rows when there is a match in one of the tables

169. what is normalisation ?

ans-The normalization process involves getting our data to conform to three progressive normal forms, and a higher level of normalization cannot be achieved until the previous levels have been achieved (there are actually five normal forms, but the last two are mainly academic and will not be discussed).

First Normal Form
The First Normal Form (or 1NF) involves removal of redundant data from horizontal rows. We want to ensure that there is no duplication of data in a given row, and that every column stores the least amount of information possible (making the field atomic).

Second Normal Form
Where the First Normal Form deals with redundancy of data across a horizontal row, Second Normal Form (or 2NF) deals with redundancy of data in vertical columns. As stated earlier, the normal forms are progressive, so to achieve Second Normal Form, your tables must already be in First Normal Form.

Third Normal Form

I have a confession to make; I do not often use Third Normal Form. In Third Normal Form we are looking for data in our tables that is not fully dependant on the primary key, but dependant on another value in the table

170. What is the maximum length of a table name, a database name, or a field name in MySQL?

ans- Database name: 64 characters
Table name: 64 characters
Column name: 64 characters

171. list of php CMS?
                              
ans - Drupal, Joomla, PhpBB, Wordpress.

172. list of frameworks in php ?

ans- Zend,CodeIgniter and CackePHP framework.

173. Difference between CMS and Framework.

ans-An application framework is something which we use to build our web application on, I mean we use the framework provided classes, events, methods and create an application.

A CMS is already a developed application with a set of features, however most of them are coded in such a way that users can tweak them around and modify the code to fit their own needs.

So a framework does not come with a working application, but a CMS comes with one.

174. Http default port no.?

ans- 80
175. Http is stateless or stateful?

ans- stateless.
176. How to unset coockie?

ans- by setting the set cookie method in back date.

    setcookie(name,value,expire,path,domain,secure)
    setcookie("TestCookie",$value, time()+3600*24);
    setcookie ("TestCookie", "", time() - 3600);
177. what is the output ?
    <?php
        $param = "value";
        $value = 10;
        print ${$param};// 10
        print $$param;// 10
        print '$$param';// $$param
    ?>
178. What is the function to upload a file?

ans - move_uploaded_file();
179. Max execution time?

ans- 30sec.
180. Max uploading size?

ans- 2Mb

181. How session starts?

ans- session_start()
82.What is ob_start()?

ans-ob_start() function turn on the output buffering, while output buffering is active no output is sent from the script, other than header.
183. how to run php file from command prompt?
184. Difference between session and cookie?
185. What is stored procedure?
186. What is the use of === ?
187. Use of static keyword?

ans-Declaring class properties or methods as static makes them accessible without needing an instantiation of the class.
188. Types of file format under mysql5->data folder?

ans- There are three types of file format
    1.frm
    2.MYD
    3.MYI

189. What are the new features added in PHP5 ?

ans- Addition features of PHP5-----
    1.Visibility
    2.Abstract
    3.Final
    4.Methods
    5.Class
    6.Magic methods or functions
    7.Interface
    8.Cloning
    9.Typehinting

190. What is AJAX ?

ans-AJAX = Asynchronous JavaScript and XML.

AJAX is a technique for creating fast and dynamic web pages.

AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

AJAX applications are browser- and platform-independent!

All modern browsers support the XMLHttpRequest object (IE5 and IE6 uses an ActiveXObject).

The XMLHttpRequest object is used to exchange data with a server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

To handle all modern browsers, including IE5 and IE6, check if the browser supports the XMLHttpRequest object. If it does, create an XMLHttpRequest object, if not, create an ActiveXObject


To send a request to a server, we use the open() and send() methods of the XMLHttpRequest object:

xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();

GET is simpler and faster than POST, and can be used in most cases.

However, always use POST requests when:

    * A cached file is not an option (update a file or database on the server)
    * Sending a large amount of data to the server (POST has no size limitations)
    * Sending user input (which can contain unknown characters), POST is more robust and secure than GET

If you want to send information with the GET method, add the information to the URL:


xmlhttp.open("GET","demo_get2.asp?fname=Henry&lname=Ford",true);
xmlhttp.send();


To POST data like an HTML form, add an HTTP header with setRequestHeader(). Specify the data you want to send in the send() method:

xmlhttp.open("POST","ajax_test.asp",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("fname=Henry&lname=Ford");


setRequestHeader(header,value) ->Adds HTTP headers to the request.

header: specifies the header name
value: specifies the header value


AJAX stands for Asynchronous JavaScript and XML, and for the XMLHttpRequest object to behave as AJAX, the async parameter of the open() method has to be set to true:

xmlhttp.open("GET","ajax_test.asp",true);

Sending asynchronously requests is a huge improvement for web developers. Many of the tasks performed on the server are very time consuming. Before AJAX, this operation could cause the application to hang or stop.

With AJAX, the JavaScript does not have to wait for the server response, but can instead:

    * execute other scripts while waiting for server response
    * deal with the response when the response ready


Async=true

When using async=true, specify a function to execute when the response is ready in the onreadystatechange event:

xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();

Async=false

To use async=false, change the third parameter in the open() method to false:

Using async=false is not recommended, but for a few small requests this can be ok.

Remember that the JavaScript will NOT continue to execute, until the server response is ready. If the server is busy or slow, the application will hang or stop.

Note: When you use async=false, do NOT write an onreadystatechange function - just put the code after the send() statement:

xmlhttp.open("GET","ajax_info.txt",false);
xmlhttp.send();
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;

The onreadystatechange event
-------------------------------

When a request to a server is sent, we want to perform some actions based on the response.

The onreadystatechange event is triggered every time the readyState changes.

The readyState property holds the status of the XMLHttpRequest.

Three important properties of the XMLHttpRequest object:

In the onreadystatechange event, we specify what will happen when the server response is ready to be processed.

When readyState is 4 and status is 200, the response is ready:

xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }


if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","gethint.php?q="+str,true);
xmlhttp.send();

91. What is main strength of Ajax ?

ans- AJAX does not refresh or reload the whole page as because Ajax uses asynchronous technology.
In a word, a program does not wait for response after requesting an asynchronous call whereas synchronous does so.

192. How session works?

ans- Nearly every PHP application uses sessions. This article takes a detailed look at implementing a secure session management mechanism with PHP. Following a fundamental introduction to HTTP, the challenge of maintaining state, and the basic operation of cookies, I will step through simple and effective methods that can be used to increase the security and reliability of your stateful PHP applications.

It is a common misconception that PHP provides a certain level of security with its native session management features. On the contrary, PHP simply provides a convenient mechanism. It is up to the developer to provide the complete solution, and as you will see, there is no one solution that is best for everyone.

Statelessness
HTTP is a stateless protocol. This is because there is nothing within the protocol that requires the browser to identify itself during each request, and there is also no established connection between the browser and the web server that persists from one page to the next. When a user visits a web site, the user's browser sends an HTTP request to the web server, which in turn sends an HTTP response in reply. This is the extent of the communication, and it represents a complete HTTP transaction.

Because the web relies on HTTP for communication, maintaining state in a web application can be particularly challenging for developers. Cookies are an extension of HTTP that were introduced to help provide stateful HTTP transactions, but privacy concerns have prompted many users to disable support for cookies. State information can be passed in the URL, but accidental disclosure of this information poses serious security risks. In fact, the very nature of maintaining state requires that the client identify itself, yet the security-conscious among us know that we should never trust information sent by the client.

Despite all of this, there are elegant solutions to the problem of maintaining state. There is no perfect solution, of course, nor is there one solution that can satisfy everyone's needs. This article introduces some techniques that can reliably provide statefulness as well as defend against session-based attacks such as session hijacking. Along the way, you will learn how cookies really work, what PHP sessions do, and what is required to hijack a session.

193.What is interface?

ans- PHP does not support multiple inheritance directly, to implement this we need Interface. It is much similar to Interface of Java.

In PHP, signature of the method are declared in the Interface body, and the body part of the method is implemented in derived class. Variables are declared as constant and it can not be changed in the child classes.

We use implement keyword to extend this kind of class, at the same time we can implement more than one interface and one interface can be implemented by another interface.

All methods declared in an interface must be public and the variables should be constant.

This is mandatory that we must declare the body part of the method in the derived class otherwise an error message will be generated.

Example:

<?php

interface Inter{

const a="This is constant value";

public function disp(); }

class A implements Inter{

function show(){

echo self::a."<br/>";}

public function disp(){

echo "Inside the disp function";}}

$a=new A();

$a->show();

$a->disp();

?>

Output:

This is constant value
Inside the disp function

194. Difference between Http and Ftp ?

ans- 1
FTP stands for File Transfer Protocol.
HTTP stands for Hyper Text Transfer Protocol
2
FTP, is a protocol used to upload files from a workstation to a FTP server or download files from a FTP server to a workstation.
HTTP, is a protocol used to transfer files from a Web server onto a browser in order to view a Web page that is on the Internet.
3
When ftp appears in a URL it means that the user is connecting to a file server and not a Web server and that some form of file transfer is going to take place.
When http appears in a URL it means that the user is connecting to a Web server and not a file server. The files are transferred but not downloaded, therefore not copied into the memory of the receiving device.
4
FTP is a two-way system as files are transferred back and forth between server and workstation.
HTTP is a one-way system as files are transported only from the server onto the workstation's browser.
5
FTP, where entire files are transferred from one device to another and copied into memory,
HTTP only transfers the contents of a web page into a browser for viewing.
6
FTP file uploaded is used in cases when the file size is more than 70 MB
HTTP upload is used for smaller files.
7
FTP uses an FTP client server and an FTP client.
HTTP is used for all web [ages i.e. it is the standard protocol to transmit hyperlinked documents and files. It is often used in conjunction with HTML.
8
FTP was the original non-GUI file transfer program and could be run from a command line interface like MS-DOS.
HTTP is associated with a browser file transfer program like Internet Explorer.

0 comments:

Post a Comment

Labels

.htaccess (5) 2step verification in php (1) 404 Page (1) Address Autocomplete (1) Admin (1) Ajax (3) alias key generation (1) All Browsers Testing (1) Android (19) Android 5.0 (2) Android Life Cycle (1) Android webview media capture (1) angular js (7) Angular Js ebook (1) AngularJS (23) Apache and mysql start up automatically once system boot (1) array_combine() (1) array_merge() (1) array_search() (1) async css and js (1) auto generate url slug in codeginiter (1) Auto reload (1) Autocomplete (1) automation code for php and mysql (1) AWS (1) AWS EC2 Hosting (6) AWS EC2 Hosting Connect with notepad++ (1) AWS ECS Hosting (1) base_url() (1) Basic php example on this keyword use (1) Best Practices to write jquery (1) Bootstrap (2) Bootstrap form tag problem (1) Bootstrap Modal (1) Bootstrap Modals (1) Breadcrumb (1) Broad band usage meter (1) Can't connect to MySQL server on (1) Cannot retrieve metalink for repository (1) Career Guidance (1) Carousel (1) Categories of websites (1) Cent OS (2) CI (1) Ci Errors (1) ckeditor (3) Clear Browser Cache Trick (1) Client IP Address (1) Code completion for codeigniter (1) Codehint for CodeIgniter (1) CodeIgniter (54) Codeigniter Controllers (1) Codeigniter email (1) Codeigniter file upload (2) Codeigniter send grid integration (1) CodeIgniter with Dreamweaver (1) Codigniter4 (1) color replace function in jquery (1) colorReplace function (1) configuration files locations (1) Controllers in controllers angular js (1) Cookies (1) core php file upload (1) count down timer in seconds in jquery (1) Countries Table in mysql (1) Create User in mysql Db (1) CryptoJS (1) CSS (3) CSS tricks (2) curl parallel calls (1) Currency API (1) Customize date format in php (1) Data dictionary (1) data of birth validation and generation codeigniter (1) Database backup in php (1) date (1) Date Difference (2) date difference in jquery (1) Date format in php (1) Date functions (1) datepicker date format jquery (1) Datetime Picker (1) datewise mysql backup (1) DBFunctions (1) Default Image in html (1) Desktop tricks (1) Detect Android Mobile (1) Detect Iphone using javascript (1) Disadvantages of Joomla (1) Disadvantages of Wordpress (1) Distance Calculation (1) document printing (1) Document submit (1) dreamweaver (1) Drupal CMS (2) Drupal Components (1) Drupal Update (1) Dynamic jQuery (21) Dynamic websites building (1) echo (1) editor for html interface (1) Email (2) Email extract in php (1) email php configuration (1) empty() and is_null() difference (1) error handling in php (1) event.PreventDefault() (1) execution time in javascript (1) extract numbers php (1) Facebook Link Posting (1) Facebook Login Error Javascript (1) Facebook Page Likes (1) Fancybox (1) Fastpanel (1) Features of Joomla (1) Features of Wordpress (1) file upload (1) File upload in jquery (1) File upload through URL with php script (1) file_get_contents (1) Files listing from folders in php (1) FileUpload (2) fileupload in jquery with preview (1) filezilla (1) Filter to top (1) Find the Framework of a website (1) Firewall Configuration in Centos (1) FOR php developers (2) Form_validation form with codeigniter (1) FTP (1) Full calendar (1) Geo API (4) Geo Code (2) Geo complete (1) Geo Location (1) GeoLocation (4) get ipaddress (1) gmail contacts api (1) Google Chrome Install (1) Google Map (1) Google Maps (9) Grant all privileges in mysql db (1) Grocery Crud (5) Guess CMS (1) hashtag (1) History Clear (1) HMVC (1) Host is not allowed to connect to MySQL Server (1) how to include header and footer html in html (1) How to prevent sql injection in php (1) how to zip file in linux (1) HTML (4) HTML CSS JS compression (1) HTML Typography (1) HTML5 (4) httpd.conf Configurations (1) Huge IT Silder (1) Hybrid App (1) Hyperlinks (1) image resize in codeigniter (1) Image with preview and remove html (1) Include() and include_once Difference (2) India States (1) Interfaces in PHP (1) Internal server error solution (1) Invoice Templates (1) ionic (13) ionic ios (1) iOS (3) iTunes (1) Javascript (45) javascript countdown timer (1) javascript email validation (1) Javascript Object properties view (1) Javascript UNIX time stamp converter (1) jmeter (3) Jquery (40) jquery datepicker (2) jquery detect idle state (1) jquery list sort (1) Jquery OWL Carousel (1) Jquery UI (1) jquery username validation (1) jquery validation (1) JS (1) JSON (3) Laravel (4) Laravel Tutorials (2) Latest Android Version (1) Linux commands (5) LINUX Ftp Configuration (1) Linux Server IP Address (1) List Sortable in Jquery UI (1) Lollipop (1) Magento (1) mail in php (1) main controller and child controller and another child controller (1) maximum execution time in php code (1) Media Capture in HTML5 (1) method overloading in php (1) method overriding in php (1) mod_rewrite (1) Mouse Deselection Javascript (1) Multidimensinal Array sort (1) multiple comparisons in php (1) Multiple file upload in Angular JS (1) Multiple file upload in jquery (1) multiple file upload in php (1) multiselect (1) Mysql (21) mysql and apache start up automatically once system boot (1) mysql connect (1) mysql connect in windows os (1) mysql database backup (1) mysql datatypes (1) Mysql DB (1) mysql Db connection program (1) Mysql Errors (1) mysql functions (1) MySQL HostName (1) mysql query tricks (1) MySQL server at 'reading initial communication packet' (1) mysql_real_escape_string() (1) mysql_secure_installation (1) mysql.sock (2) Error (1) mysqli (2) Native App (1) Netbeans for linux (1) Network usage monitor (1) ng-bind (1) ng-click (1) Node js (1) Notepad++ (1) onchange display images (1) Online UNIX Timestamp to human readble format converter (1) OOPS in php (1) Pagination in Codeigniter (1) Pagination in php (1) Password encryption and decryption in php (1) Paypal (1) PayU Form (1) PDF (1) PDO (2) Pendrive Data Recovery (1) php (62) PHP 5.4.0 (2) php abstract class example (1) PHP ajax file upload (2) PHP ajax request detection (1) PHP Basic Login and logout (1) PHP Codeigniter database backup code (1) PHP Contact us email form code (1) PHP corn jobs (1) php database backup script (1) php email validation (1) PHP Environment Setup (1) PHP Errors (1) PHP Extension and Application Repository) (1) php file upload (1) PHP File Uploading (1) PHP fileupload helper in codeigniter (1) PHP interview questions (4) PHP lamda functions examples (1) PHP Login (1) PHP pdo (1) PHP PDO script to insert data inside mysql db (1) PHP Random Password generation Script (2) php script execution limit (1) php script to display months (1) php script to print years as dropdown (1) PHP Storm (2) PHP Storm license key (1) PHP strong encryption and decryption (1) php timeslot generator (1) php-mysql Modules (1) phpmyadmin (2) phpMyAdmin install (1) Pin-code finder (1) Pincode (1) Play youtube video in angular JS (1) Popup (2) POPUP in javascript (1) POST and GET Difference (1) POST DATA IN PHP (1) Postfix sendmail (1) preview of selected file (1) Print content with jquery (1) print() (1) Push Notifications (1) query string based pagination in codeigniter (1) Random key (1) ratings (1) regular expressions (1) remote validation (1) remove query string (1) Remove Sale Tag or Logo of woocommerce (1) Repository (1) require_once() (1) require() (1) Resize Image Dynamically (1) result_array() (1) rpmdb open fail (1) Salaries (1) SCP Command syntax (1) select images display in webbrowser (1) Selected values in javascript (1) Send free sms (1) Send Grid (1) Send Grid Email integration (1) SEO PHP (1) Session Management in PHP (1) show active class in the url automatically php (1) Show alternate image (1) simple ajax php script (1) Simple Login in PHP (1) Simple registraion (1) single file upload (1) site2sms script (1) Slideshow (1) SMTP Configuration (2) SOFTWARE TECHNOLOGY TIPS (1) Sort list items by Mouse in jquery (1) sprintf in php (1) SQL Injection in php (1) States Countries API (1) static variable in javascript (1) store date in php (1) stripslashes() (1) strtotime (1) sum of array values (1) sumo select (1) system error: 113 (1) Talk To Camera (1) Text to ASCII Generator (1) this keyword (1) Time ago function in javascript (1) Time ago Plugin (1) Time in PHP (1) time picker in grocery crud admin (1) Timeslot Generation in PHP (1) Tooltips using css (1) trigger in mysql (1) ubuntu (1) UNIX timestamp to HUMan readable converter (1) use full tutorials (1) user ur domain inseted of localhost (1) validation in javascript (1) Version Controls for PHP (1) Webmin (1) What CMS (1) Why Drupal CMS (1) Windows 10 (1) Windows Commands (1) Wordpress (2) Xampp (2) Xampp Localhost (1) Xampp Security (1) Yii Framework configuration (1) Yii framework installation (1) ZipArchive (1) ZipArchive php aws (1)
 
TOP