| |
Our Testimonials |
|
| |
|
|
| 1. What is Difference between Abstract Class and Interface. |
| 2. What is difference between php4 and php5? |
| 3. What is Difference between GET and POST |
| 4. What's the difference between COPY OF A FILE & MOVE_UPLOAD_FILE in file uploading? |
| 5. How do you create subdomains using PHP? |
| 6. How can I maintain the count of how many persons have hit my site? |
| 7. What is meant by PEAR in php? |
| 8. What is the functionality of MD5 function in PHP? |
| 9. How can we know the number of days between two given dates using PHP? |
| 10. What is the difference between $message and $$message? |
| 11. How can I execute a PHP script using command line? |
| 12. What type of inheritance that php supports? |
| 13. How can we repair a MySQL table? |
| 14. What Is a Persistent Cookie? |
| 15. What is meant by urlencode and urldecode? |
| 16. How To Create a Table? |
| 17. How can we send mail using JavaScript? |
| 18. How To Protect Special Characters in Query String? |
| 19. What are the differences between DROP a table and TRUNCATE a table? |
| 20. What is the difference between GROUP BY and ORDER BY in SQL? |
| 21. HOW CAN WE TAKE A BACKUP OF A MYSQL TABLE AND HOW CAN WE RESTORE IT? |
| 22. What are the advantages of stored procedures, triggers, indexes? |
| 23. What changes I have to do in php.ini file for file uploading? |
| |
|
|
|
1. What is Difference between Abstract Class and Interface.
|
Abstract Classes
An abstract class can provide some functionality and leave the rest for derived class
The derived class may or may not override the concrete functions defined in base class
The child class extended from an abstract class should logically be related
Interface
An interface cannot contain any functionality. It only contains definitions of the methods
The derived class must provide code for all the methods defined in the interface
Completely different and non-related classes can be logically be grouped together using an interface
In the interface all methods must be abstract; in the abstract class some methods can be concrete
interface contains variables that must be static and final; abstract class may contain non-final and final variables. members in an interface are public by default, abstract class may contain non-public members. interface is used to "implements"; whereas abstract class is used to "extends". |
|
|
2. What is difference between php4 and php5?
|
php4 cannot support oops concepts and zend engine1 will be used
in php5 support oops concepts and zends engine2 will be used
error supporting will increased in php5
xml and sqllite will be incresed in php5 |
|
|
3. What is Difference between GET and POST
|
GET:
1. URL Changes to the submitted script name, appended with a list
of each variable with the value.
2. Use only if the number of variable to be used in a form ar very less.
3. Never use GET forms when asking for login ID and passwords.
4. Even hidden variables are shown as a part of the URL.
5. A lot of webservers might complain about long URLs being submitted.
A lot of times a URL 255 char or more is a problem.
6. We can bookmark link with this method
POST:
1. This is the best way of submitting forms to the web server.
2. There is no limitation on the number of Variables passed from the form.
3. This is a transparent way of transmitting variables to the webserver
where hidden variable are always hidden!
4. We can not bookmark page link |
|
|
4. What's the difference between COPY OF A FILE & MOVE_UPLOAD_FILE in file uploading?
|
Answer: Move : This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.
If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.
Copy :Makes a copy of a file. Returns TRUE if the copy succeeded, FALSE otherwise. |
|
|
5. How do you create subdomains using PHP?
|
Answer: In you main httpd.conf, add the following line at the bottom:Include /path/to/subdomains.conf file name subdomains.conf@mkdir ( "/path/to/subdirectory/".$name );   $vhost = "   ServerAdmin yourname@yourserver.com   DocumentRoot /path/to/subdirectory/".$name." ... |
|
|
6. How can I maintain the count of how many persons have hit my site?
|
session_start();//error_reporting(E_ALL);
if(!isset($_SESSION['count'])){
$_SESSION['count']=0;
}else{
$_SESSION['count']++;
} |
|
|
7. What is meant by PEAR in php?
|
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"
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. The project has been founded by Stig S. Bakken in 1999 and quite a lot of people have joined the project since then. |
|
|
8. 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. |
|
|
9. How can we know the number of days between two given dates using PHP?
|
Simple arithmetic:
$date1 = date('Y-m-d');
$date2 = '2006-07-01';
$days = (strtotime() - strtotime()) / (60 * 60 * 24);
echo "Number of days since '2006-07-01': $days"; |
|
|
10. What is the difference between $message and $$message?
|
Anwser:
$message is a simple variable whereas $$message is a reference variable. Example:
$user = 'bob'
is equivalent to
$holder = 'user';
$$holder = 'bob'; |
|
|
11. How can I execute a PHP script using command line?
|
ust 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. |
|
|
12. 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'. |
|
|
13. 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. |
|
|
14. 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. |
|
|
15. What is meant by urlencode and urldecode?
|
Anwser 1:
urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode("10.00%") will return "10%2E00%25". URL encoded strings are safe to be used as part of URLs.
urldecode() returns the URL decoded version of the given string.
Anwser 2:
string urlencode(str) - Returns the URL encoded version of the input string. String values to be used in URL query string need to be URL encoded. In the URL encoded version:
Alphanumeric characters are maintained as is.
Space characters are converted to "+" characters.
Other non-alphanumeric characters are converted "%" followed by two hex digits representing the converted character.
string urldecode(str) - Returns the original string of the input URL encoded string.
For example:
$discount ="10.00%";
$url = "http://domain.com/submit.php?disc=".urlencode($discount);
echo $url;
You will get "http://domain.com/submit.php?disc=10%2E00%25". |
|
|
16. How To Create a Table?
|
If you want to create a table, you can run the CREATE TABLE statement as shown in the following sample script:
include "mysql_connection.php";
$sql = "CREATE TABLE Tech_links ("
. " id INTEGER NOT NULL"
. ", url VARCHAR(80) NOT NULL"
. ", notes VARCHAR(1024)"
. ", counts INTEGER"
. ", time TIMESTAMP DEFAULT sysdate()"
. ")";
if (mysql_query($sql, $con)) {
print("Table Tech_links created.\n");
} else {
print("Table creation failed.\n");
}
mysql_close($con);
?>
Remember that mysql_query() returns TRUE/FALSE on CREATE statements. If you run this script, you will get something like this:
Table Tech_links created |
|
|
17. How can we send mail using JavaScript?
|
No. There is no way to send emails directly using JavaScript.
But you can use JavaScript to execute a client side email program send the email using the "mailto" code. Here is an example:
function myfunction(form)
{
tdata=document.myform.tbox1.value;
location="mailto:mailid@domain.com?subject=...";
return true;
} |
|
|
18. 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. The script below shows how to use urlencode():
print("");
print("Please click the links below"
." to submit comments about TECHPreparation.com: ");
$comment = 'I want to say: "It\'s a good site! :->"';
$comment = urlencode($comment);
print(""
.""
."It's an excellent site! ");
$comment = 'This visitor said: "It\'s an average site! :-("';
$comment = urlencode($comment);
print(""
.''
."It's an average site. ");
print("");
?> |
|
|
19. What are the differences between DROP a table and TRUNCATE a table?
|
DROP TABLE table_name - This will delete the table and its data.
TRUNCATE TABLE table_name - This will delete the data of the table, but not the table definition. |
|
|
20. 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]; Tells DBMS according to what columns it should sort the result. If two rows will have the same value in col1 it will try to sort them according to col2 and so on.
GROUP BY [col1],[col2],...[coln]; Tells DBMS to group (aggregate) 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. |
|
|
21. HOW CAN WE TAKE A BACKUP OF A MYSQL TABLE AND HOW CAN WE RESTORE IT?
|
Answer 1:
Create a full backup of your database: shell> mysqldump tab=/path/to/some/dir opt db_name
Or: shell> mysqlhotcopy db_name /path/to/some/dir
The full backup file is just a set of SQL statements, so restoring it is very easy:
shell> mysql "."Executed";
Answer 2:
To backup: BACKUP TABLE tbl_name TO /path/to/backup/directory
’ To restore: RESTORE TABLE tbl_name FROM /path/to/backup/directory
mysqldump: Dumping Table Structure and Data
Utility to dump a database or a collection of database for backup or for transferring the data to another SQL server (not necessarily a MySQL server). The dump will contain SQL statements to create the table and/or populate the table.
-t, no-create-info
Don't write table creation information (the CREATE TABLE statement).
-d, no-data
Don't write any row information for the table. This is very useful if you just want to get a dump of the structure for a table! |
|
|
22. What are the advantages of stored procedures, triggers, indexes?
|
A stored procedure is a set of SQL commands that can be compiled and stored in the server. Once this has been done, clients don't need to keep re-issuing the entire query but can refer to the stored procedure. This provides better overall performance because the query has to be parsed only once, and less information needs to be sent between the server and the client. You can also raise the conceptual level by having libraries of functions in the server. However, stored procedures of course do increase the load on the database server system, as more of the work is done on the server side and less on the client (application) side. Triggers will also be implemented. A trigger is effectively a type of stored procedure, one that is invoked when a particular event occurs. For example, you can install a stored procedure that is triggered each time a record is deleted from a transaction table and that stored procedure automatically deletes the corresponding customer from a customer table when all his transactions are deleted. Indexes are used to find rows with specific column values quickly. Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more this costs. If the table has an index for the columns in question, MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. If a table has 1,000 rows, this is at least 100 times faster than reading sequentially. If you need to access most of the rows, it is faster to read sequentially, because this minimizes disk seeks. |
|
|
23. What changes I have to do in php.ini file for file uploading?
|
Make the following line uncomment like:
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = C:\apache2triad\temp
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M |
|