Вы находитесь на странице: 1из 48

What are the differences between Get and post methods in form submitting, give the case

where we can use get and we can use post methods?

In the get method the data made available to the action page ( where data is received ) by
the URL so data can be seen in the address bar. Not advisable if you are sending login
info like password etc.In the post method the data will be available as data blocks and not
as query string.

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

What is the difference between $message and $$message?

Both are two variables. In the second case the value of the $message will be substituted
in the $message part and a new variable will create. i.e., $message is a simple variable
whereas $$message is a reference variable.
Example:
$user = 'bob' is equivalent to
$holder = 'user';
$$holder = 'bob';
Anwser 2:
They are both variables. But $message is a variable with a fixed name. $$message is a
variable who's name is stored in $message. For example, if $message contains "var",
$$message is the same as $var.

What is difference between require_once(), require(), include().

Difference between require() and require_once(): require() includes and evaluates a


specific file, while require_once() does that only if it has not been included before (on the
same page).So, require_once() is recommended to use when you want to include a file
where you have a lot of functions for example.
Difference between require() and include() is that require() produces a FATAL ERROR if
the file you want to include is not found, while include() only produces a WARNING.
There is also include_once() which is the same as include(), but the difference between
them is the same as the difference between require() and require_once().

What is the difference between echo and print statement?

echo() can take multiple expressions,Print cannot take multiple expressions.


echo has the slight performance advantage because it doesn't have a return value.
I need to convert all single-quotes (') in a string to a backslash followed by a single-
quote. How can I do this with a regular expression?
First off, take a look at the addslashes() function. It will do exactly what you want. You
should also have a look at the magic_quotes_gpc directive in your php.ini file.The
ereg_replace magic you're looking for, however, is simply:

$escaped = ereg_replace("'", "\'", $input);

When I do the following, the output is printed in the wrong order:

function myfunc($argument) {
echo $argument + 10;
}
$variable = 10;
echo "myfunc($variable) = " . myfunc($variable);

What's going on?

To be able to use the results of your function in an expression (such as concatenating it


with other strings in the example above), you need to return the
value, not echo it.

What type of inheritance that php supports?

In 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'.

What are the differences between mysql_fetch_array(), mysql_fetch_object(),


mysql_fetch_row()?

mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or


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

Explain different types of errors in php (i.e. arguments in error reporting function)?

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

What is meant by nl2br()?

nl2br — Inserts HTML line breaks before all newlines in a string string nl2br (string);
Returns string with ‘’ inserted before all newlines. For example: echo nl2br("god blessn
you") will output "god bless n you" to your browser.

How can we get second of the current time using date function?

$second = date("s");

What is the difference between the functions unlink and unset?

unlink() deletes the given file from the file system.


unset() makes a variable undefined.

How can we increase the execution time of a php script?

Set max_execution_time variable in php.ini file to your desired time in second.

How many ways can we get the value of current session id?

session_id() returns the session id for the current session.

How can we destroy the session, how can we unset the variable of a session?

session_unregister — Unregister a global variable from the current session


session_unset — Free all session variables

How can we destroy the cookie?

Set the cookie in past

How many ways we can pass the variable through the navigation between the pages?

GET or QueryString and POST

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

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

How can we know the count/number of elements of an array?

2 ways
a) sizeof($urarray) This function is an alias of count()
b) count($urarray)

interestingly if u just pass a simple var instead of a an array it will return 1.

What Is a Session?

A session is a logical object created by the PHP engine to allow you to preserve data
across subsequent HTTP requests.
There is only one session object available to your PHP scripts at any time. Data saved to
the session by a script can be retrieved by the same script or another script when
requested from the same visitor.
Sessions are commonly used to store temporary data to allow multiple PHP pages to offer
a complete functional transaction for the same visitor.

What is meant by PEAR in php?

Answer1:
PEAR is the next revolution in PHP. This repository is bringing higher level
programming to PHP. PEAR is a framework and distribution system for reusable PHP
components. It eases installation by bringing an automated wizard, and packing the
strength and experience of PHP users into a nicely organised OOP library. PEAR also
provides a command-line interface that can be used to automatically install "packages"
Answer2:
PEAR is short for "PHP Extension and Application Repository" and is pronounced just
like the fruit. The purpose of PEAR is to provide:
A structured library of open-sourced code for PHP users
A system for code distribution and package maintenance
A standard style for code written in PHP
The PHP Foundation Classes (PFC),
The PHP Extension Community Library (PECL),
A web site, mailing lists and download mirrors to support the PHP/PEAR community
PEAR is a community-driven project with the PEAR Group as the governing body.

What does a special set of tags <?= and ?> do in PHP?

The output is displayed directly to the browser.


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 is the difference between the functions unlink and unset?

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.

What’s the difference between htmlentities() and htmlspecialchars()?

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

What is the functionality of MD5 function in PHP?

string md5(string)
It calculates the MD5 hash of a string. The hash is a 32-character hexadecimal number.

How can we know that a session is started or not?

A session starts by session_start() function.


This session_start() is always declared in header portion. it always declares first. then we
write session_register().

What are the differences between mysql_fetch_array(), mysql_fetch_object(),


mysql_fetch_row()?

mysql_fetch_array() -> Fetch a result row as a combination of associative array and


regular array.
mysql_fetch_object() -> Fetch a result row as an object.
mysql_fetch_row() -> Fetch a result set as a regular array().

How can we increase the execution time of a php script?

By the use of void set_time_limit(int seconds)


Set the number of seconds a script is allowed to run. If this is reached, the script returns a
fatal error. The default limit is 30 seconds or, if it exists,
the max_execution_time value defined in the php.ini. If seconds is set to zero, no time
limit is imposed.
When called, set_time_limit() restarts the timeout counter from zero. In other words, if
the timeout is the default 30 seconds, and 25 seconds into script
execution a call such as set_time_limit(20) is made, the script will run for a total of 45
seconds before timing out.

How to set cookies?

setcookie('variable','value','time');
variable - name of the cookie variable
value - value of the cookie variable
time - expiry time
Example: setcookie('Test',$i,time()+3600);
Test - cookie variable name
$i - value of the variable 'Test'
time()+3600 - denotes that the cookie will expire after an one hour

How to reset/destroy a cookie

Reset a cookie by specifying expire time in the past:


Example: setcookie('Test',$i,time()-3600); // already expired time
Reset a cookie by specifying its name only
Example: setcookie('Test');

what about ob_start and ob_flush?

ob_start is used to start the output buffer


ob_flush is used to refresh or clear the output buffer

xplain Constructors and Destructors in php?

__construct( )
Called when instantiating an object
__destruct( )
Called when deleting an object
Constructors and destructors are functions that are called when a new instance of an
object is created (constructors) and/or destroyed (destructors). Their primary purpose is to
allow for a means to initialize and clean up after an object during its use.Constructors can
accept parameters, which are assigned to specific object fields at creation time.
Constructors can call class methods or other functions.constructors are intuitively useful
for initializing class properties,Class constructors can call on other constructors,
including those from the class parent.One classic example is a class to access a database
back end, where a constructor could make the connection to the database while the
destructor closes it.
PHP 4 Constructors
In PHP 4, only constructors were available and were created by defining a function
whose name was the same as the class itself:
<?php
class MyClass {
function MyClass($param) {
echo "Created a new instance of MyClass !";
}
}
$Myinstance = new MyClass;
?>
In PHP 5, this concept has been changed PHP 5 or (5>=) now uses a unified constructor
function named __construct(). PHP 5 or (5>=) also uses a unified
__destruct() method for its destructors.
PHP 5 Constructors and Destructors
<?php
class MyClass {
function __construct($p) {
echo "Created a new instance of MyClass!";
}
function __destruct() {
echo "Destroyed this instance of MyClass";
}
}
$Myinstance = new MyClass("value");

?>

Define class in php?

A class is a blueprint of an object ,variables and functions (called methods),

How PHP Supports Encapsulation?

Encapsulation is the mechanism that binds together code and data it manipulates and
keeps both safe from out side interference and miss use .To implement this concept ,
PHP 5 supports public, private, and protected variables and member functions .

How many HTTP headers will send to a web page(client side) from server when you use
sessions (session_start()) in php ?

There are three HTTP headers included in the response:


Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache

what are the advantages of storing sessions in database?

If you store a session in a database you have several advantages:


@ Improving the security because on many hosting packages (shared host)
PHP uses the same path for storing sessions for all the users,
somewhere that is not in your folders.
@ You can track who is online etc.
@ For application that are running on multiple servers, you can store
all the session data in one database.
The real beauty of this approach is that you don't have to modify your code or the way
you use sessions in any way. $_SESSION still exists and behaves the
same way, PHP still takes care of generating and propagating the session identifier, and
changes made to session configuration directives still apply. All
you have to do is call this one function.
You must call session_set_save_handler() prior to calling session_start(), but you can
define the functions themselves anywhere.
The function is called session_set_save_handler(), and it takes six arguments,
1. Opening the session data store
2. Closing the session data store
3. Reading session data
4. Writing session data
5. Destroying all session data
6. Cleaning out old session data

How to capture content from the output buffer ? or Give me an example for Output
caching in php?

<?php
ob_start(); // start an output buffer
echo ‘This text is from the codlib buffer*******<br />’; // output that will be stored in
the buffer
$codlib = ob_get_contents(); // store buffer content in $w3buffer variable
ob_end_clean(); // stop and clean the output buffer
echo ‘This is not from the codlib buffer!!!!!!!!<br />’;
echo $codlib;
?>
O/p
*****
This is not from the codlib buffer!!!!!!!!
This text is from the codlib buffer*******

Which function in PHP gives us absolute path of a file on the server?

<?php
$p = getcwd();
echo $p;
?>

When I try to connect to mysql from php I get this error: "Call to unsupported or
undefined function mysql_connect();"

Either you are missing mysql support in the php module or you need to load mysql
dynamicly in your scripts by inserting:
dl("mysql.so"); (on unix)
dl("mysql.dll"); (on windows);
in the top of all the scripts that use mysql.
But it is recomended to compile php with mysql.
How can I send variables from a PHP script to another URL using POST without using
forms and hidden variables?

You can open an HTTP socket connection and send HTTP POST commands. Here is
an example :
<?
// Generate the request header
$ReqHeader =
"POST $URI HTTP/1.1n".
"Host: $Hostn".
"Content-Type: application/x-www-form-urlencodedn".
"Content-Length: $ContentLengthnn".
"$ReqBodyn";

// Open the connection to the host


$socket = fsockopen($Host, 80, &$errno, &$errstr);
if (!$socket)
$Result["errno"] = $errno;
$Result["errstr"] = $errstr;
return $Result;
}
$idx = 0;
fputs($socket, $ReqHeader);
while (!feof($socket))
$Result[$idx++] = fgets($socket, 128);
}
//-------------------------------------------
?>
Or you can use the cURL extensions for PHP (http://curl.haxx.se). Once you build it and
compile their support into PHP, it is fairly easy to do posting stuff (even over https):
<?
$URL="www.mysite.com/test.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://$URL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "Data1=blah&Data2=blah");curl_exec
($ch);
curl_close ($ch);
?>
This will have the net effect of posting your data to the $URL site, without any header
hacking.You can also do other nifty things with cURL, like retrieve the HTML into
variables and scrape through it for neat functionality.

How do I insert javascript in php code?

You just echo / print the javascript like you would do with html, like:
<?
echo "<script language="JavaScript">n";
echo "alert("javascript from php");n";
echo "</script>";
?>
How to count number of parameters given in URL by POST?

<?
echo count ($_POST);
?>

How to output a number with leading zero's?

<?
$number = 15;
printf("%05d", $number);
?>

Can I get the screen resolution and like with php?

The quick answer is no, then you are probably asking why can't I do that with php. OK
here is a longer answer. PHP is a serverside scripting language and therefor has nothing
to do with the type of a specific client. Then you might ask "why can I then get the
browser agent from php?", thats because that information is sent with the initial HTTP
headers upon requst to the server. So if you want client information that's not sent with
the HTTP header you must a client scripting language like javascript.

Why doesn't rand give random numbers?


I use the following code
$iRandom = rand(0,100);
But I dotn get random numbers, whats wrong?

You have not RTFM'ed good enough, if you read the man page for rand carefully you will
find a line that states:
"Remember to seed the random number generator before use with srand()."
So the proper code would be:
srand((double)microtime()*1000000);
$iRandom = rand(0,100);
As an alternative you can use mt_rand which should generate more random, numbers.

MYSQL

What these files contains?

In 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,
How can we find the number of rows in a table using mysql?

Use this for mysql


>SELECT COUNT(*) FROM table_name;
but if u r particular about no of rows with some special result do this
>SELECT [colms],COUNT(*) FROM table_name [where u put conditions];

How can we find the number of rows in a result set using php?

$result = mysql_query($any_valid_sql, $database_link);


$num_rows = mysql_num_rows($result);
echo "$num_rows rows found";

How many ways we can we find the current date using mysql?

SELECT CURDATE();
CURRENT_DATE() = CURDATE();
for time use
SELECT CURTIME();
CURRENT_TIME() = CURTIME();

The structure of table view buyers is as follows


+—————-+————-+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+—————-+————-+——+—–+———+—————-+
| user_pri_id | int(15) | | PRI | NULL | auto_increment |
| userid | varchar(10) | YES | | NULL | |
+—————-+————-+——+—–+———+—————-+
the value of user_pri_id the last row 2345 then What will happen in
the following conditions
Condition1: Delete all the rows and insert another row then What is the starting value for
this auto incremented field user_pri_id ,
Condition2: Delete the last row(having the field value 2345) and insert another row then
What is the value for this auto incremented field user_pri_id

In both cases let the value for auto increment field be n then next row will have value n+1
i.e. 2346

How can increase the performance of mysql select query?

In general, when you want to make a slow SELECT … WHERE query faster, the first
thing to check is whether you can add an index. All references between different tables
should usually be done with indexes. You can use the EXPLAIN statement to determine
which indexes are used for a SELECT.
To help MySQL optimize queries better, use ANALYZE TABLE or run myisamchk –
analyze on a table after it has been loaded with data. This updates a value for each index
part that indicates the average number of rows that have the same value. (For unique
indexes, this is always 1.) MySQL will use this to decide which index to choose when
you join two tables based on a non-constant expression. You can check the result from the
table analysis by using SHOW INDEX FROM tbl_name and examining the Cardinality
value. myisamchk –description –verbose shows index distribution information.
To sort an index and data according to an index, use myisamchk –sort-index –sort-
records=1 (if you want to sort on index 1). This is a good way to make queries faster if
you have a unique index from which you want to read all records in order according to
the index. Note that the first time you sort a large table this way, it may take a long time.

What is the difference between GROUP BY and ORDER BY in Sql?

To sort a result, use an ORDER BY clause.


The most general way to satisfy a GROUP BY clause is to scan the whole table and
create a new temporary table where all rows from each group are consecutive, and then
use this temporary table to discover groups and apply aggregate functions (if any).
ORDER 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

How can we change the name of a table?

MySQL query to rename table: RENAME TABLE tbl_name TO new_tbl_name


[, tbl_name2 TO new_tbl_name2] …
or,
ALTER TABLE tableName CHANGE OldName newName.

How can we repair a mysql table?

The syntex for repairing a mysql table is


REPAIR TABLE tablename
REPAIR TABLE tablename QUICK
REPAIR TABLE tablename EXTENDED
This command will repair the table specified.
If QUICK is given, MySQL will do a repair of only the index tree.
If EXTENDED is given, it will create index row by row.

What is the maximum length of a table name, database name, and fieldname in mysql?

Database name- 64
Table name -64
Fieldname-64
What are the other commands to know the structure of table using mysql commands
except explain command?

describe table_name;

Write query for creating a table.

CREATE TABLE codlib_questions ("


. " id INTEGER NOT NULL"
. ", question VARCHAR(80) NOT NULL"
. ", answer VARCHAR(1024)"
. ", sort_order INTEGER"
. ", created_time TIMESTAMP DEFAULT sysdate()"
. ")

How many ways we can we find the current date using MySQL?

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

How can we encrypt and decrypt a data present in a mysql table using mysql?

AES_ENCRYPT() and AES_DECRYPT()

How can we know the number of days between two given dates using MySQL?

Use DATEDIFF()
SELECT DATEDIFF(NOW(),'2006-07-01');

How can we change the name of a column of a table?

This will change the name of column:


ALTER TABLE table_name CHANGE old_colm_name new_colm_name

How can we change the data type of a column of a table?

This will change the data type of a column:


ALTER TABLE table_name CHANGE colm_name same_colm_name [new data type]

Which clause is used to select unique records of the table?

DISTINCT

How would you select all the users, whose email address is null(empty)?
SELECT usrname FROM customers WHERE ISNULL(usremail);

What happens when the column is set to AUTO INCREMENT and we reach the
maximum valuen for that table?

It stops incrementing. It does not move to 0 to prevent data losses, but further inserts are
going to produce an error

How do you prevent mysql from caching a query?

SELECT SQL_NO_CACHE
include this (SQL_NO_CACHE) in select query while you retrieve the data from mysql

What is the Use of "WITH ROLLUP" in Mysql?

Adding a WITH ROLLUP modifier to the GROUP BY clause causes the query to
produce another row.
eg:
mysql> SELECT year, SUM(profit) FROM sales GROUP BY year WITH ROLLUP;
+------+-------------+
| year | SUM(profit) |
+------+-------------+
| 2000 | 4525 |
| 2001 | 3010 |
| NULL | 7535 | <<<- Note here*
+------+-------------+
So an extra row (<<<- Note here*) is created by mysql and also we get total profit
in the last column.

what is the use of –i-am-a-dummy flag in MySql?

It Makes the MySQL engine refuse UPDATE and DELETE commands where the
WHERE clause is not present.

How many types of buffers does use MySQL?

global buffers and per-connection buffers

How can I set the time zone for MySQL to UK time?

If you set the environment variable TZ=GB, then start MySQL the time zone will be set
to UK time.
I.E. (Linux only)
bash:#TZ=GB
bash:#export TZ
bash:#mysqld &
You can also set environment variables in my.cnf; In the data (normally var) directory.

I am trying to create a database and keep getting an error :- (Errcode: 28)

errcode: 28
No space left on device
This means that you are out of disk space.
Try du to see how much space is free/used

JavaScript

What is JavaScript?

JavaScript is a platform-independent,event-driven, interpreted client-side scripting and


programming language developed by Netscape Communications Corp. and Sun
Microsystems.

What can javascript programs do?

Generation of HTML pages on-the-fly without accessing the Web server. The user can be
given control over the browser like User input validation Simple computations can be
performed on the client's machine. The user's browser, OS, screen size, etc. can be
detected Date and Time Handling

How can we submit from without a submit button?

we can use javascript for submitting the form. Trigger the JavaScript code on any event
( like onselect of drop down list box, onfocus, etc )

document.myform.submit();

This will submit the form.

CSS

What are the advantages and disadvantages of CASCADE STYLE SHEETS?

External Style Sheets


Advantages
Can 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 contexts
Disadvantages
An 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 definitions
Embedded 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

What are Style Sheets?

Stylesheets, as the name suggest, define styles (look and feel) for the content that HTML
holds. One can re-use same set of CSS styles over number of pages

throughout the website to keep a consistent look and feel. Stylesheets help web designers
keep the HTML clean and separate styles from the content.

What is the importance of Cascade in CSS?

One doesn't have to declare repeating styles for the child elements. E.g. if <body> has a
font-name style set to Arial, by default all the elements in the
HTML document will inherit this property, unless defined separately.

What is CLASS selector?

Using CLASS selectors in CSS one can assign style information to all elements. Class
selectors name in CSS is preceded by full stop.
The class selectors which can be applied multiple times to different element within a
page to format content.

What is the cascading order of a CSS style sheet?

Generally speaking we can say that all the styles will "cascade" into a new "virtual" style
sheet by the following rules, where number four has the highest priority:
1. Browser default
2. External style sheet
3. Internal style sheet (inside the <head> tag)
4. Inline style (inside an HTML element)
So, an inline style (inside an HTML element) has the highest priority, which means that it
will override a style declared inside the <head> tag, in an external style sheet, or in a
browser (a default value).

What are the two parts of CSS declaration?

Property and value

What is at-rule in CSS?

The at-rule in CSS begins with the at-keyword. It is then followed by '@' character and
then the identifier. Some of the at-rule in CSS are '@import', '@page'.

What are the types of CSS rules?

There are three types of CSS rules. They are namely:


HTML Selector
Class and
ID

waht is first-line pseudo-element?

The "first-line" pseudo-element is used to add special styles to the first line of the text in
a selector:
p {font-size: 12pt}
p:first-line {color: #FF0000;font-variant:small-caps}
<p>Some text that ends up on two or more lines</p>
In the example above the browser displays the first line formatted according to the "first-
line" pseudo element. Where the browser breaks the line depends on the size of the
browser window.
Note: The "first-line" pseudo-element can only be used with block-level elements.
Note: The following properties apply to the "first-line" pseudo-element:
* font properties
* color properties
* background properties
* word-spacing
* letter-spacing
* text-decoration
* vertical-align
* text-transform
* line-height
* clear
Pseudo-elements can also be combined with CSS classes:
p.article:first-line {color: #FF0000}
<p class="article">A paragraph in an article</p>
The example above will set the first line of all paragraphs with class="article" to red.

what is selector?

In the CSS Rule-Set syntax, a 'Selector' is used to specify the portion of the document
tree that the style declaration that follows will be attached to.
A Selector is the portion of a Rule-Set that comes before the style Declaration Block
embedded within curly braces ('{' and '}'.)

How will you apply more than one class per given element?

To apply more than one class per given element, the syntax is:
<p class="center bold">
This is a paragraph.
</p>
The paragraph above will be styled by the class "center" AND the class "bold".
How will you add Styles to Elements with Particular Attributes?

You can also apply styles to HTML elements with particular attributes.
The style rule below will match all input elements that have a type attribute with a
value of "text":
input[type="text"] {background-color: blue}

How will you define styles for HTML elements with the id selector?

You can define styles for HTML elements with the id selector. The id selector is defined
as a #.
The style rule below will match the element that has an id attribute with a value of
"green":
#green {color: green}
The style rule below will match the p element that has an id with a value of "para1":
p#para1
{
text-align: center;
color: red
}

Waht is Aural Style Sheets?

Aural style sheets use a combination of speech synthesis and sound effects to make the
user listen to information, instead of reading information.
Aural presentation can be used:
* by blind people
* to help users learning to read
* to help users who have reading problems
* for home entertainment
* in the car
* by print-impaired communities
The aural presentation converts the document to plain text and feed this to a screen reader
(a program that reads all the characters on the screen).

An example of an Aural style sheet:


h1, h2, h3, h4
{
voice-family: male;
richness: 80;
cue-before: url("beep.au")
}
The example above will make the speech synthesizer play a sound, then speak the
headers in a very rich male voice.

Database

What is Query Joins?

A join is a temporary relationship that you can create between two tables in a database
query that do not already have an established relationship or common field with the same
fieldname or data type. Database tables that are joined in a query are related in that query
only, and nowhere else. The type of join that you use indicates which records the query
will select or perform the chosen actions on.
Note: Creating a query join will not establish a permanent relationship between the
tables.

What is primary Key?

The primary key of a relational table uniquely identifies each record in the table. It can
either be a normal attribute that is guaranteed to be unique (such as Social Security
Number in a table with no more than one record per person) or it can be generated by the
DBMS (such as a globally unique identifier, or GUID, in Microsoft SQL Server). Primary
keys may consist of a single attribute or multiple attributes in combination.
Which ever key is help us to identify a record uniquely in a database table is called
primary key.

What's a Database Abstraction Layer?

Abstraction is a technique which simplifies something complex. It does this by removing


non-essential parts of the object, allowing us to concentrate on the important parts.
In the case of database abstraction, the complexities of connecting to a database is hidden
behind a standard API, thereby allowing the programmer to connect to many different
types of databases without relearning the methods and syntax peculiar to each different
type.

Explain Normalization concept?

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

object-oriented-programming

What are the features and advantages of OBJECT ORIENTED PROGRAMMING?

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.

What are the differences between PROCEDURE ORIENTED LANGUAGES and


OBJECT ORIENTED LANGUAGES?

Traditional programming has the following characteristics:

Functions are written sequentially, so that a change in programming can affect any code
that follows it.
If a function is used multiple times in a system (i.e., a piece of code that manages the
date), it is often simply cut and pasted into each program (i.e., a change log, order
function, fulfillment system, etc). If a date change is needed (i.e., Y2K when the code
needed to be changed to handle four numerical digits instead of two), all these pieces of
code must be found, modified, and tested.
Code (sequences of computer instructions) and data (information on which the
instructions operates on) are kept separate. Multiple sets of code can access and modify
one set of data. One set of code may rely on data in multiple places. Multiple sets of code
and data are required to work together. Changes made to any of the code sets and data
sets can cause problems through out the system.
Object-Oriented programming takes a radically different approach:
Code and data are merged into one indivisible item – an object (the term "component"
has also been used to describe an object.) An object is an abstraction of a set of real-world
things (for example, an object may be created around "date") The object would contain
all information and functionality for that thing (A date
object it may contain labels like January, February, Tuesday, Wednesday. It may contain
functionality that manages leap years, determines if it is a business day or a holiday, etc.,
See Fig. 1). Ideally, information about a particular thing should reside in only one place
in a system. The information within an object is encapsulated (or hidden) from the rest of
the system.A system is composed of multiple objects (i.e., date function, reports, order
processing, etc., See Fig 2). When one object needs information from another object, a
request is sent asking for specific information. (for example, a report object may need to
know what today’s date is and will send a request to the date object) These requests are
called messages and each object has an interface that manages messages.
OO programming languages include features such as "class", "instance", "inheritance",
and "polymorphism" that increase the power and flexibility of an object.

What’s the difference between accessing a class method via -> and via ::?

:: is allowed to access methods that can perform static operations, i.e. those, which do not
require object initialization.

What is the use of friend function?

Sometimes 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 whichnames 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.

class mylinkage
{
private:
mylinkage * prev;
mylinkage * next;
protected:
friend void set_prev(mylinkage* L, mylinkage* N);
void set_next(mylinkage* L);

public:
mylinkage * succ();
mylinkage * pred();
mylinkage();
};
void mylinkage::set_next(mylinkage* L) { next = L; }
void set_prev(mylinkage * L, mylinkage * N ) { N->prev = L; }
Friends in other classes
It is possible to specify a member function of another class as a friend as follows:
class C
{
friend int B::f1();
};
class B
{
int f1();
};
It is also possible to specify all the functions in another class as friends, by specifying the
entire class as a friend.
class A
{
friend class B;
};
Friend functions allow binary operators to be defined which combine private data in a
pair of objects. This is particularly powerful when using the operator overloading features
of C++. We will return to it when we look at overloading.

XML

Describe the differences between XML and HTML?

XML HTML
User definable tags Defined set of tags designed for
web display
Content driven Format driven
End tags required for well formed End tags not required
documents
Quotes required around attributes Quotes not required
values
Slash required in empty tags Slash not required
What is XML?

XML (Extensible Markup Language) is a standard for creating markup languages which
describe the structure of data. It is not a fixed set of elements like HTML, but rather, it is
like SGML (Standard Generalized Markup Language) in that it is a metalanguage, or a
language for describing languages. XML enables authors to define their own tags.

* XML stands for EXtensible Markup Language


* XML is a markup language much like HTML
* XML was designed to describe data
* XML tags are not predefined. You must define your own tags
* XML uses a Document Type Definition (DTD) or an XML Schema to describe the
data
* XML with a DTD or XML Schema is designed to be self-descriptive
* XML is a W3C Recommendation

General Web

What is online payment gateway?

An online payment gateway is the interface between your merchant account and your
Web site. The online payment gateway allows you to immediately verify credit card
transactions and authorize funds on a customer's credit card directly from your Web site.
It then passes the transaction off to your merchant bank for processing, commonly
referred to as transaction batching.

What is mean by server-side scripting?

Server-side scripting is a web server technology in which a user's request is fulfilled by


running a script directly on the web server to generate dynamic HTML pages. It is
usually used to provide interactive web sites that interface to databases or other data
stores.

server-side scripts are executed by the web server when the user requests a document.
They produce output in a format understandable by web browsers (usually HTML),
which is then sent to the user's computer. The user cannot see the script's source code
(unless the author publishes the code separately), and may not even be aware that a script
was executed. The documents produced by server-side scripts may, of course, contain
client-side scripts.

What Is a Persistent Cookie?

A persistent cookie is a cookie which is stored in a cookie file permanently on the


browser's computer. By default, cookies are created as temporary cookies which stored
only in the browser's memory. When the browser is closed, temporary cookies will be
erased. You should decide when to use temporary cookies and when to use persistent
cookies based on their differences:
* Temporary cookies can not be used for tracking long-term information.
* Persistent cookies can be used for tracking long-term information.
* Temporary cookies are safer because no programs other than the browser can access
them.
*
* Persistent cookies are less secure because users can open cookie files see the cookie
values.

What is meant by MIME?

Answer 1:
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
Answer 2:
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. …

What is RSS and why it is Important?

RSS (formally "RDF Site Summary", known colloquially as "Really Simple


Syndication") is a family of Web feed formats used to publish frequently updated content
such as blog entries, news headlines or podcasts. An RSS document, which is called a
"feed", "web feed", or "channel", contains either a summary of content from an
associated web site or the full text. RSS makes it possible for people to keep up with their
favorite web sites in an automated manner that's easier than checking them manually.
RSS content can be read using software called an "RSS reader", "feed reader" or an
"aggregator". The user subscribes to a feed by entering the feed's link into the reader or
by clicking an RSS icon in a browser that initiates the subscription process. The reader
checks the user's subscribed feeds regularly for new content, downloading any updates
that it finds.
The initials "RSS" are used to refer to the following formats:
* Really Simple Syndication (RSS 2.0)
* RDF Site Summary (RSS 1.0 and RSS 0.90)
* Rich Site Summary (RSS 0.91)
what is mean by Client-side scripting?

Client-side scripting generally refers to the class of computer programs on the web that
are executed client-side, by the user's web browser, instead of server-side (on the web
server). This type of computer programming is an important part of the Dynamic HTML
(DHTML) concept, enabling web pages to be scripted; that is, to have different and
changing content depending on user input, environmental conditions (such as the time of
day), or other variables.Web authors write client-side scripts in languages such as
JavaScript (Client-side JavaScript), which is based on several standards:
Client-side scripts are often embedded within an HTML document, but they may also be
contained in a separate file, which is referenced by the document (or documents) that use
it. Upon request, the necessary files are sent to the user's computer by the web server (or
servers) on which they reside. The user's web browser executes the script, then displays
the document, including any visible output from the script. Client-side scripts may also
contain instructions for the browser to follow if the user interacts with the document in a
certain way, e.g., clicks a certain button. These instructions can be followed without
further communication with the server, though they may require such communication.
By viewing the file that contains the script, users may be able to see its source code.
Many web authors learn how to write client-side scripts partly by examining the source
code for other authors' scripts.

what is mean by Content management system(CMS)?

A content management system (CMS) is a system used to manage the content of a Web
site.[1] Content management systems are deployed primarily for interactive use by a
potentially large number of contributors.The content managed includes computer files,
image media, audio files, electronic documents and web content. The idea behind a CMS
is to make these files available inter-office, as well as over the web.
A web content management system is a content management system with additional
features to ease the tasks required to publish web content to web sites.
Web content management systems are often used for storing, controlling, versioning, and
publishing industry-specific documentation such as news articles, operators' manuals,
technical manuals, sales guides, and marketing brochures. A content management system
may support the following features:
* only of documents and multimedia material
* Identification of all key users and their content management roles
* The ability to assign roles and responsibilities to different content categories or types.
* Definition of the content workflow tasks, often coupled with event messaging so that
content managers are alerted to changes in content.
* The ability to track and manage multiple versions of a single instance of content.
* The ability to publish the content to a repository to support access to the content.
Increasingly, the repository is an inherent part of the system, and incorporates enterprise
search and retrieval.
* Some content management systems do allow the textual aspect of content to be
separated to some extent from formatting. For example the CMS may automatically set
default color, fonts, or layouts.
what is a mashup?

Mashups are an exciting genre of interactive Web applications that draw upon content
retrieved from external data sources to create entirely new and innovative services. They
are a hallmark of the second generation of Web applications informally known as Web
2.0.
A mashup is a website or application that combines content from more than one source
into an integrated experience.
In technology, a mashup is a web application that combines data from more than one
source into a single integrated tool; an example is the use of cartographic data from
Google Maps to add location information to real-estate data from Craigslist, thereby
creating a new and distinct web service that was not originally provided by either source.

What is a template?

A template is a framework for web pages and sites. Templates for web pages work much
like templates in Microsoft Word, or any other word processing application.

===========================================
What are the differences between Get and post methods in form submitting.
give the case where we can use get and we can use post methods?

When to use GET or POST

The HTML 2.0 specification says, in section Form Submission (and the HTML 4.0
specification repeats this with minor stylistic changes):

–>If the processing of a form is idempotent (i.e. it has no lasting observable effect on the
state of the world), then the form method should be GET. Many database searches
have no visible side-effects and make ideal applications of query forms.

–>If the service associated with the processing of a form has side effects (for example,
modification of a database or subscription to a service), the method should be POST.

How the form data is transmitted?

quotation from the HTML 4.0 specification

–> If the method is “get” - -, the user agent takes the value of action, appends a ? to it,
then appends the form data set, encoded using the application/x-www-form-urlencoded
content type. The user agent then traverses the link to this URI. In this scenario, form data
are restricted to ASCII codes.
–> If the method is “post” –, the user agent conducts an HTTP post transaction using the
value of the action attribute and a message created according to the content type specified
by the enctype attribute.

Quote from CGI FAQ


Firstly, the the HTTP protocol specifies differing usages for the two methods. GET
requests should always be idempotent on the server. This means that whereas one GET
request might (rarely) change some state on the Server, two or more identical requests
will have no further effect.This is a theoretical point which is also good advice in
practice. If a user hits “reload” on his/her browser, an identical request will be sent to the
server, potentially resulting in two identical database or guestbook entries, counter
increments, etc. Browsers may reload a GET URL automatically, particularly if cacheing
is disabled (as is usually the case with CGI output), but will typically prompt the
user before re-submitting a POST request. This means you’re far less likely to
get inadvertently-repeated entries from POST.

GET is (in theory) the preferred method for idempotent operations, such as querying a
database, though it matters little if you’re using a form. There is a further practical
constraint that many systems have built-in limits to the length of a GET request they can
handle: when the total size of a request (URL+params) approaches or exceeds 1Kb, you
are well-advised to use POST in any case.I would prefer POST when I don’t want the
status to be change when user resubmits. And GET when it does not matter.

Who is the father of PHP and explain the changes in PHP versions?
Rasmus Lerdorf is known as the father of PHP.PHP/FI 2.0 is an early and no longer
supported version of PHP. PHP 3 is the successor to PHP/FI 2.0 and is a lot nicer. PHP 4
is the current generation of PHP, which uses the Zend engine under the hood. PHP 5 uses
Zend engine 2 which, among other things, offers many additionalOOP features
How can we submit a form without a submit button?
The main idea behind this is to use Java script submit() function in order to submit the
form without explicitly clicking any submit button. You can attach the
document.formname.submit() method to onclick, onchange events of different inputs and
perform the form submission. You can even built a timer function where you can
automatically submit the form after xx seconds once the loading is done (can be seen in
online test sites).
In how many ways we can retrieve the data in the result set of MySQL using PHP?
You can do it by 4 Ways
1. mysql_fetch_row.
2. mysql_fetch_array
3. mysql_fetch_object
4. mysql_fetch_assoc
What is the difference between mysql_fetch_object andmysql_fetch_array?
mysql_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).
What is the difference between $message and $$message?
It is a classic example of PHP’s variable variables. take the following example.$message
= “Mizan”;$$message = “is a moderator of PHPXperts.”;$message is a simple PHP
variable that we are used to. But the $$message is not a very familiar face. It creates a
variable name $mizan with the value “is a moderator of PHPXperts.” assigned. break it
like this${$message} => $mizanSometimes it is convenient to be able to have variable
variable names. That is, a variable name which can be set and used dynamically.
How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’
using regular expression of PHP?
preg_match(”/^http:\/\/.+@(.+)$/”,’http://info@abc.com’,$found);
echo $found[1];
How can we create a database using PHP and MySQL?
We can create MySQL database with the use of mysql_create_db(“Database Name”)
What are the differences between require and include,include_once and
require_once?

The include() statement includes and evaluates the specified file.The documentation
below also applies to require(). The two constructs are identical in every way except how
they handle failure. include() produces a Warning while require() results
in a Fatal Error. In other words, use require() if you want a missing file to halt processing
of the page. include() does not behave this way, the script will continue regardless.The
include_once() statement includes and evaluates the specified file during the execution
of the script. This is a behavior similar to the include() statement, with the only
difference being that if the code from a file has already been included, it will not be
included again. As the name suggests, it will be included just once.include_once()
should be used in cases where the same file might be included and evaluated more than
once during a particular execution of a script, and you want to be sure that it is included
exactly once to avoid problems with function redefinitions, variable value reassignments,
etc.require_once() should be used in cases where the same file might be included and
evaluated more than once during a particular execution of a script, and you want to be
sure that it is included exactly once to avoid problems with function redefinitions,
variable value reassignments, etc.

Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”?


Yes we can use include() more than one time in any page though it is not a very good
practice.
What are the different tables present in MySQL, which type of table is generated
when we are creating a table in the following syntax: create table employee (eno
int(2),ename varchar(10)) ?
Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM
MyISAM is the default storage engine as of MySQL 3.23 and as a result if we do not
specify the table name explicitly it will be assigned to the default engine.
Functions in IMAP, POP3 AND LDAP?
You can find these specific information in PHP Manual.
How can I execute a PHP script using command line?
As of version 4.3.0, PHP supports a new SAPI type (Server Application Programming
Interface) named CLI which means Command Line Interface. Just run the PHP CLI
(Command Line Interface) program and provide the PHP script file name as the
command line argument. For example, “php myScript.php”, assuming “php” is the
command to invoke the CLI program.Be aware that if your PHP script was written for the
Web CGI interface,it may not execute properly in command line environment.
Shopping cart online validation i.e. how can we configure Paypal,etc.?
We can find the detail documentation about different paypal integration process at the
following site

PayPal PHP
SDK : http://www.paypaldev.org

What is meant by nl2br()?


Inserts HTML line breaks (<BR /&gt before all newlines in a string string nl2br
(string); Returns string with ” inserted before all newlines. For example: echo nl2br(”god
bless\n you”) will output “god bless <br /> you” to your browser.
Draw the architecture of Zend engine?
The Zend Engine is the internal compiler and runtime engine used by PHP4. Developed
by Zeev Suraski and Andi Gutmans, the Zend Engine is an abbreviation of their names.
In the early days of PHP4, it worked as
follows:

The PHP script was loaded by the Zend Engine and compiled into Zend opcode.
Opcodes, short for operation codes, are low level binary instructions. Then the opcode
was executed and the HTML generated sent to the client. The opcode was flushed from
memory after execution.Today, there are a multitude of products and techniques to help
you speed up this process. In the following diagram, we show the how modern
PHP scripts work; all the shaded boxes are optional.

PHP Scripts are loaded into memory and compiled into Zend opcodes.
What are the current versions of apache, PHP, and MySQL?
As of February, 2007 the current versions are PHP: php5.2.1
MySQL: MySQL 5.2,Apache: Apache 2.2.4
Note: visit www.php.net,
http://dev.mysql.com/downloads/mysql/,
www.apache.org to get current versions.
What are the reasons for selecting lamp (Linux, apache, MySQL,PHP) instead of
combination of other software programs, servers and operating systems?
All 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.
How can we encrypt and decrypt a data present in a MySQL table
using MySQL?
AES_ENCRYPT () and AES_DECRYPT ()
How can we encrypt the username and password using PHP?
The functions in this section perform encryption and decryption, and compression and
uncompression:
encryption decryption
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 available UNCOMPRESSED_LENGTH()
What are the features and advantages of object-oriented programming?
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
What are the differences between procedure-oriented languages and
object-oriented languages?
Traditional programming has the following characteristics:Functions are written
sequentially, so that a change in programming can affect any code that follows it.
If a function is used multiple times in a system (i.e., a piece of code that manages the
date), it is often simply cut and pasted into each program (i.e., a change log, order
function, fulfillment system, etc).If a date change is needed (i.e., Y2K when the code
needed to be changed to handle four numerical digits instead of two), all these pieces of
code must be found, modified, and tested.Code (sequences of computer instructions) and
data (information on which the instructions operates on) are kept separate. Multiple sets
of code can access and modify one set of data. One set of code may rely on data in
multiple places. Multiple sets of code and data are required to work together. Changes
made to any of the code sets and data sets can cause problems through out the
system.Object-Oriented programming takes a radically different approach:Code and data
are merged into one indivisible item – an object (the term “component” has also been
used to describe an object.) An object is an abstraction of a set of real-world things (for
example, an object may be created around “date”) The object would contain all
information and functionality for that thing (A date object it may contain labels like
January, February, Tuesday, Wednesday.It may contain functionality that manages leap
years, determines if it is a business day or a holiday, etc., See Fig. 1). Ideally, information
about a particular thing should reside in only one place in a system.The information
within an object is encapsulated (or hidden) from the rest of the system.A system is
composed of multiple objects (i.e., date function, reports,order processing, etc., See Fig
2). When one object needs information from another object, a request is sent asking for
specific information.(for example, a report object may need to know what today’s date is
and will send a request to the date object) These requests are called messages and each
object has an interface that manages messages.OO programming languages include
features such as “class”, “instance”,“inheritance”, and “polymorphism” that increase the
power and flexibility of an object.
What is the use of friend function?
Sometimes 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.
What are the different types of errors in PHP?
Three 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.
What are the differences between PHP 3 and PHP 4 and PHP 5?
Please read the release notes at http://www.php.net.
How can we convert asp pages to PHP pages?
There 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./
What is the functionality of the function htmlentities?
Convert 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.
How can we get second of the current time using date function?
$second = date(”s”);
How can we convert the time zones using PHP?
By 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>';?>
What is meant by urlencode and urldocode?
URLencode 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.
What is the difference between the functions unlink and unset?
unlink() deletes the given file from the file system.unset() makes a variable undefined.
How can we register the variables into a session?
$_SESSION[’name’] = “Mizan”;
How can we take a backup of a MySQL table and how can we restore it. ?
To 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-infoDon’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!
How can we optimize or increase the speed of a MySQL select query?

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

How many ways can we get the value of current session id?
session_id() returns the session id for the current session.
How can we destroy the session, how can we unset the variable of a session?
session_unregister — Unregister a global variable from the current session
session_unset — Free all session variables
How can we destroy the cookie?
Set the cookie in past.
How many ways we can pass the variable through the navigation
between the pages?

• GET/QueryString
• POST

How can we know the count/number of elements of an array?


2 ways
a) sizeof($urarray) This function is an alias of count()
b) count($urarray)
What is the PHP predefined variable that tells the What types of images that PHP
supports?
Though i am not sure if this is wrong or not, With the exif extension you are able to work
with image meta data.
How can I know that a variable is a number or not using a JavaScript?
bool 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.
List out some tools through which we can draw E-R diagrams for mysql.
Case Studio,Smart Draw
How can I retrieve values from one database server and store them in other
database server using PHP?
we 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);

Thanks goes to Hasan and Hasin for this solution.

List out the predefined classes in PHP?


Directory
stdClass
__PHP_Incomplete_Class
exception
php_user_filter
How can I make a script that can be bi-language (supports English, German)?
You 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.
What are the difference between abstract class and interface?
Abstract 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.
How can we send mail using JavaScript?
JavaScript 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.
How can we repair a MySQL table?
The 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
What is the maximum length of a table name, database name, and
fieldname in MySQL?
The following table describes the maximum length for each type of
identifier.
Maximum Length
Identifier
(bytes)
Database 64
Table 64
Column 64
Index 64
Alias 255

There are some restrictions on the characters that may appear in


identifiers:

What are the other commands to know the structure of table using
MySQL commands except explain command?
describe Table-Name;
Give the syntax of Grant and Revoke commands?
The 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
Explain Normalization concept?
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 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

How can we find the number of rows in a table using MySQL?


Use this for mysql
>SELECT COUNT(*) FROM table_name;
How can we find the number of rows in a result set using PHP?
$result = mysql_query($sql, $db_link);
$num_rows = mysql_num_rows($result);
echo “$num_rows rows found”;
How many ways we can we find the current date using MySQL?
SELECT CURDATE();
CURRENT_DATE() = CURDATE()
for time use
SELECT CURTIME();
CURRENT_TIME() = CURTIME()
What are the advantages and disadvantages of Cascading Style
Sheets?
External 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

What type of inheritance that PHP supports?


In 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’.

The structure of table view buyers is as follows:


Field Type Null Key Default Extra
user_pri_id int(15) PRI null auto_increment
userid varchar(10) YES null
the value of user_pri_id the last row 999 then What will happen in
the following conditions?

Condition1: Delete all the rows and insert another row then.
What is the starting value for this auto incremented field user_pri_id ,
Condition2: Delete the last row(having the field value 999) and
insert another row then. What is the value for this auto incremented
field user_pri_id

In both cases let the value for auto increment field be n then next
row will have value n+1 i.e. 1000
What are the advantages/disadvantages of MySQL and PHP?
Both of them are open source software (so free of cost), support
cross platform. php is faster then ASP and JSP.
What is the difference between GROUP BY and ORDER BY in Sql?
ORDER 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

What is the difference between char and varchar data types?


Set 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 ‘mizan’, if each char
takes a byte eg. name varchar(15) will just use 5 bytes if we store ‘mizan’, if each
char takes a byte. rest 10 bytes will be free.
What is the functionality of md5 function in PHP? Calculate 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.
How can we know the number of days between two given dates using
PHP?
$date1 = date(’Y-m-d’);
$date2 = ‘2006-08-15′;
$days = (strtotime($date1) - strtotime($date2)) / (60 * 60 * 24);
What is ‘float’ property in CSS?
The float property sets where an image or a text will appear in another element.
What is descendant structure in CSS?
Descendant selectors are used to select elements that are descendants of another
element in the document tree.For example, you may wish to target a specific <em>
element on the page, but not all <em> elements. A sample document could contain
the following code: <body>
<h1>Heading <em>here</em> </h1>
<p>Lorem ipsum dolor <em>sit</em> amet.</p>
</body> The document tree diagram (with the <em> element to be targeted) would
be: If you use a type selector like the example below, you will
select all <em> elements on the page:

em {color: blue; } However, if you use a descendant selector, you can refine the
<em> elements that you select. The rule below will only select <em> elements that
are descendants of <p> elements. If this rule is applied, the <em> element within
the <h1> will not be colored blue.

p em {color: blue; } You can also jump levels in the document tree structure to
select descendants. For example, the following code:

<body>
<p>Lorem ipsum dolor <em>sit</em> amet.</p>
<ul>
<li>item 1</li>
<li>item 2</li>
<li><em>item 3</em></li>
</ul>
</body> The document tree (with a third-level <em> element highlighted) would
be:

Using the following rule you can isolate any <em> element inside a <ul> element,
without having to describe the <li> element. If this rule is applied, any <em>
element within a <ul> element will be colored blue. However, the <em> element
within the <p> will not be colored blue:

ul em {color: blue; } Descendant selectors are well supported across standards-


compliant browsers.
What is Child Descendant structure in CSS?

Child selectors

A child selector is used to select an element that is a direct child of another element
(parent). Child selectors will not select all descendants, only direct children.
For example, you may wish to target an <em> that is a direct child of a <div>, but
not other <em> elements that are descendants of the <div>. A sample document
could contain the following code:

<body>
<h1>Heading <em>text</em></h1>
<div>
This is some <em>text</em>
<p>This is a paragraph of <em>text</em></p>
</div>
</body>
The document tree (highlighting the <em> that is a child of the <div&gt would be:

Using the following rule you can target any <em> element that is a child of the
<div>. Other <em> elements that are descendants but not direct children of the
<div> will not be targeted.

div > em { color: blue; }

OR

div>em { color: blue; }


Child selectors are not supported by Windows Internet Explorer 5, 5.5 and 6, but are
supported by most other standards-compliant browsers.
. How to create a class in JavaScript?
Classes can seem off-putting at first, but once you see the point of them, their use
can be invaluable.We have already met objects. A computer object is a
representation of a real object. For an estate agent the object may be a house,
including information about the number of rooms and the price.An estate agent may
have a lot of houses available. These houses all have different characteristics, and as
objects they all go through the same processes. They are viewed, surveyed and
bought, and so on.A full estate agent program would be difficult to demonstrate
here, but we can introduce the use of classes.In this example, we have the house
class. The house class produces house objects, all with object properties, such as
number of rooms and price, and all having access to the same methods, such as sold
and bought.

So a class can create objects with a group of properties and methods.

JavaScript doesn’t have a keyword specific to class, so we must go back to basics


and develop classes in a different way. This isn’t very difficult.
Class Properties

Let us examine a very small estate agent program.

<HTML>
<HEAD>
<TITLE>Estate Agent</TITLE>
<SCRIPT>
function House(rooms,price,garage) {
this.rooms=rooms;
this.price=price;
this.garage=garage;
}
house1=new House(4,100000,false);
house2=new House(5,200000,true);
with (house1) document.write(’House 1 has ‘+rooms+’ rooms, ‘+(garage?’a':’no’)+’
garage, and costs £’+price+’<BR>’);
with (house2) document.write(’House 2 has ‘+rooms+’ rooms, ‘+(garage?’a':’no’)+’
garage, and costs £’+price+’<BR>’);
</SCRIPT>
</HEAD>
</HTML>

We define a House function that takes three parameters, rooms, price and garage.
The function uses the this keyword to create an object.

When we call the House function, we assign the result to our variable, which
becomes an object.

So, identical code would be:

house1=new Object();
house1.rooms=4;
house1.price=100000;
house1.garage=false;

We would have to type this in for all houses, which would be very tedious and is why
we use the class structure instead.

When we display the details for a house, I have introduced the ternary operator, ‘?:’.
The ternary operator is a compacted version of:

if (garage) str=’a'; else str=’no’;

(garage?’a':’no’) means if garage is true, return ‘a’ else return ‘no’. Using the ternary
operator removes a line of code, and avoids having to create a new variable.

Class Methods

The House class we have so far defined only contains object properties. We could add
a method to replace the document.write() action we used before. (See example)
<HTML>
<HEAD>
<TITLE>Estate Agent 2</TITLE>
<SCRIPT>
function House(name,rooms,price,garage) {
this.name=name;
this.rooms=rooms;
this.price=price;
this.garage=garage;
this.view=view;
}
function view() {
with (this) document.write(name+’ has ‘+rooms+’ rooms, ‘+(garage?’a':’no’)+’
garage, and costs £’+price+’<BR>’);
}
house1=new House(’House 1′,4,100000,false);
house2=new House(’Big House’,5,200000,true);
house1.view();
house2.view();
</SCRIPT>
</HEAD>
</HTML>

Much better!

Note how we must add another property, name, so that we can identify the house in
question. This offers more flexibility than re-using the variable name, and the
variable name is inaccessible anyway, i.e. it is very difficult, if not impossible, to get
the view() function to use the string ‘house1′.
Are namespaces are there in JavaScript?
A namespace is a container and allows you to bundle up all your functionality using a
unique name. In JavaScript, a namespace is really just an object that you’ve
attached all further methods, properties and objects. But it is not always necessary
to use namespace.
What is JSON? What are the notations used in JSON?
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is
easy for humans to read and write. It is easy for machines to parse and generate. It
is based on a subset of the JavaScript Programming Language, Standard ECMA-262
3rd Edition - December 1999. JSON is a text format that is completely language
independent but uses conventions that are familiar to programmers of the C-family
of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others.
These properties make JSON an ideal data-interchange language.
How you provide security for PHP application?
There are many ways to accomplish the security tasks but the most common 7 ways
are1. Validate Input. Never trust your user and always filter input before taking it to
any operation.2. Provide access control.3. Session ID protection4. preventing Cross
Site Scripting (XSS) flaws

5. SQL injection vulnerabilities.

6. Turning off error reporting and exposing to the site for hackers. Instead use log
file to catch exceptions
7. Effective Data handling
What is SQL Injection in PHP security?
SQL injection attacks are extremely simple to defend against, but many applications
are still vulnerable. Consider the following SQL statement:
<?php
$sql = "INSERT
INTO users (reg_username,
reg_password,
reg_email)
VALUES ('{$_POST['reg_username']}’,
‘$reg_password’,
‘{$_POST['reg_email']}’)”;
?>

This query is constructed with $_POST, which should immediately look suspicious.

Assume that this query is creating a new account. The user provides a desired
username and an email address. The registration application generates a temporary
password and emails it to the user to verify the email address. Imagine that the user
enters the following as a username:

bad_guy', 'mypass', ''), ('good_guy

This certainly doesn’t look like a valid username, but with no data filtering in place,
the application can’t tell. If a valid email address is given (shiflett@php.net, for
example), and 1234 is what the application generates for the password, the SQL
statement becomes the following:

<?php

$sql = "INSERT
INTO users (reg_username,
reg_password,
reg_email)
VALUES ('bad_guy', 'mypass', ''),
('good_guy',
'1234',
'shiflett@php.net')"; ?>

Rather than the intended action of creating a single account (good_guy) with a valid
email address, the application has been tricked into creating two accounts, and the
user supplied every detail of the bad_guy account.

While this particular example might not seem so harmful, it should be clear that
worse things could happen once an attacker can make modifications to your SQL
statements.

For example, depending on the database you are using, it might be possible to send
multiple queries to the database server in a single call. Thus, a user can potentially
terminate the existing query with a semicolon and follow this with a query of the
user’s choosing.
MySQL, until recently, does not allow multiple queries, so this particular risk is
mitigated. Newer versions of MySQL allow multiple queries, but the corresponding
PHP extension (ext/mysqli) requires that you use a separate function if you want to
send multiple queries (mysqli_multi_query() instead of mysqli_query()). Only
allowing a single query is safer, because it limits what an attacker can potentially do.

Protecting against SQL injection is easy:

• Filter your data.This cannot be overstressed. With good data filtering in place,
most security concerns are mitigated, and some are practically eliminated.
• Quote your data.If your database allows it (MySQL does), put single quotes
around all values in your SQL statements, regardless of the data type.

Escape your data.Sometimes valid data can unintentionally interfere with the format
of the SQL statement itself. Use mysql_escape_string() or an escaping function
native to your particular database. If there isn’t a specific one, addslashes() is a
good last resort.
What is cross site Scripting?
To understand what Cross Site Scripting is, let’s see a usual situation,
common to many sites. Let’s say we are taking some information
passed in on a querystring (the string after the (?) character within a
URL), with the purpose of displaying the content of a variable, for
example, the visitor’s name:

http://www.yourdomain.com/welcomedir/welcomepage.php?name=John
As we can see in this simple querystring, we are passing the visitor’s
name as a parameter in the URL, and then displaying it on our
“welcomepage.php” page with the following PHP code:

<?php

echo ‘Welcome to our site ’ . stripslashes($_GET[‘name’]);

?>
The result of this snippet is shown below:

Welcome to our site John


This is pretty simple and straightforward. We’re displaying the content of the “name”
variable, by using the $_GET superglobal PHP array, as we have done probably
hundreds of times. Everything seems to be fine. Now, what’s wrong with this code?
Nothing really. But let’s modify the querystring by replacing our visitor’s name
passed in the URL:

http://www.yourdomain.com/welcomedir/
welcomepage.php?name=John
with something like this:

http://www.yourdomain.com/welcomedir/
welcomepage.php?name=
<script language=javascript>alert
(‘Hey, you are going to be hijacked!’);</script>
Do you remember the PHP code included in our “welcome.php” page? Yes, you’re
correct. When we modify the querystring, the following code is executed:

<?php

echo ‘Welcome to our site ‘ .


<script language=javascript> alert(‘Hey, you are going
to be hijacked!’);</script>

?>
The output of this code is an alert JavaScript box telling you “Hey, you are going be
hijacked!” after the “Welcome to our site” phrase.

Very ugly stuff, right? That’s a simple example of the Cross Site Scripting
vulnerability. This means that any pasted JavaScript code into the URL will be
executed happily with no complaints at all.
Which method do you follow to get a record from a million records?
(Searching, …. not from database, from an array in php)
use array_search(), array_keys(), array_values(), array_key_exists(), and
in_array().
93. Which sorting method is lowest time consumable?
HeapSort, Merge sort are the lowest time consumable sorting algorithm.

94. Which sorting method is lowest memory consumable?

What are the differences between GET and POST methods in form submitting, give
the case where we can use get and we can use post methods?
Answer:
On the server side, the main difference between GET and POST is where the submitted is
stored. The $_GET array stores data submitted by the GET method. The $_POST array
stores data submitted by the POST method.On the browser side, the difference is that data
submitted by the GET method will be displayed in the browser's address field. Data
submitted by the POST method will not be displayed anywhere on the browser.GET
method is mostly used for submitting a small amount and less sensitive data. POST
method is mostly used for submitting a large amount or sensitive data.

Who is the father of php and explain the changes in php versions?

Answer:
Rasmus Lerdorf for version changes go to http://php.net/.Marco Tabini is the founder and
publisher of php|architect.

How can we submit from without a submit button?


Answer:
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. For example:

How many ways we can retrieve the date in result set of mysql Using php?
Answer:
As individual objects so single record or as a set or arrays.

Explain normalization concept?


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
What’s the difference between accessing a class method via -> and via ::?
:: is allowed to access methods that can perform static operations, i.e. those, which do not
require object initialization.
What are the advantages and disadvantages of CASCADE STYLE SHEETS?
External Style Sheets
Advantages
Can 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 contexts
Disadvantages
An 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 definitions
Embedded 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
Disadvantage
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
What type of inheritance that php supports?
In 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'.
How can we change the name of a column of a table?
MySQL query to rename table: RENAME TABLE tbl_name TO new_tbl_name
or,
ALTER TABLE tableName CHANGE OldName newName.
When you want to show some part of a text displayed on an HTML page in red font
color? What different possibilities are there to do this? What are the
advantages/disadvantages of these methods?
There are 2 ways to show some part of a text in red:
1. Using HTML tag <font color="red">
2. Using HTML tag <span style="color: red">
When viewing an HTML page in a Browser, the Browser often keeps this page in its
cache. What can be possible advantages/disadvantages of page caching? How can
you prevent caching of a certain page (please give several alternate solutions)?
When you use the metatag in the header section at the beginning of an HTML Web page,
the Web page may still be cached in the Temporary Internet Files folder.
A page that Internet Explorer is browsing is not cached until half of the 64 KB buffer is
filled. Usually, metatags are inserted in the header section of an HTML document, which
appears at the beginning of the document. When the HTML code is parsed, it is read from
top to bottom. When the metatag is read, Internet Explorer looks for the existence of the
page in cache at that exact moment. If it is there, it is removed. To properly prevent the
Web page from appearing in the cache, place another header section at the end of the
HTML document. For example:
What are the different ways to login to a remote server? Explain the means,
advantages and disadvantages?
There is at least 3 ways to logon to a remote server:
Use ssh or telnet if you concern with security
You can also use rlogin to logon to a remote server.
Please give a regular expression (preferably Perl/PREG style), which can be used to
identify the URL from within a HTML link tag.
Try this: /href="([^"]*)"/i
How can I use the COM components in php?
The COM class provides a framework to integrate (D)COM components into your PHP
scripts.
string COM::COM( string module_name [, string server_name [, int codepage]]) - COM
class constructor.
Parameters:
module_name: name or class-id of the requested component.
server_name: name of the DCOM server from which the component should be fetched. If
NULL, localhost is assumed. To allow DCOM com, allow_dcom has to be set to TRUE
in php.ini.
codepage - specifies the codepage that is used to convert php-strings to unicode-strings
and vice versa. Possible values are CP_ACP, CP_MACCP, CP_OEMCP, CP_SYMBOL,
CP_THREAD_ACP, CP_UTF7 and CP_UTF8.
Usage:
$word->Visible = 1; //open an empty document
$word->Documents->Add(); //do some weird stuff
$word->Selection->TypeText("This is a test…");
$word->Documents[1]->SaveAs("Useless test.doc"); //closing word
$word->Quit(); //free the object
$word->Release();
$word = null;
How many ways we can give the output to a browser?
HTML output
PHP, ASP, JSP, Servlet Function
Script Language output Function
Different Type of embedded Package to output to a browser

Вам также может понравиться