Monday, June 1, 2009

PHP

1.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 you want to send short or small data,not containing ASCII characters, then you can use “GET” Method. But for long data sending say more then 100 character you can use “POST” method. Once most imp diff is when you are sending the form with

“Get” method. You can see the output which you are sending in the addressbar. Whereas if you send the form with “POST” method then user can not see that information.


2.How can we submit a form without a submit button?

I can submit a form in many ways, for e.g.

1. When user click on checkbox, or drop down

2. When user click on radio button

3. At the end of the form I will type “Click here

to submit” & link text to the processing file


3.What is the difference between mysql_fetch_object and mysql_fetch_array?

mysql_fetch_object() is similar to mysql_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). Note: Field names returned by this function are case-sensitive.

field;

/* this is invalid */

echo $row->0;


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

1. $message is variable whereas $$message is Dynamic variable.

eg.

$user=”bob”

is equivalent to

$holder=”user”;

$$holder=”bob”;


5.What are the differences between require and include, include_once?

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. The major difference between include() and require() is that in failure include produces a warning message whereas require produces a Fatal errors.


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

yes we can use. If abc.php contains classes or functions it will give errors that same class or function is already existed. Otherwise it won’t give any error.


7.How can I execute a PHP script using command line?

Through php parse you can execute PHP script using command line. By default location of php parser is /var/www/html so set the path of this directory and just use as following

#php sample.php


8.What is meant by nl2br()?

nl2br() inserts html in string

echo nl2br(”god bless \n you”);

output

god bless

you


9.What are the current versions of apache, PHP, and mysql?

Php 5, mysql 5, Apache 2


10.What are the reasons for selecting lamp (linux, apache, mysql, PHP) instead of combination of other software programmes, servers and operating systems?

All are open source.


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

date(‘s’)


12.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 will set UNSET the variable. e.g


13.How can we destroy the cookie?
Set the cookie in past


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

Sessions, cookies, hidden variables, get, post


15.What are the different functions in sorting an array?

Usort, ksort, uksort, asort

16.In how many ways we can retrieve the date in the result set of mysql using PHP?

mysql> SELECT DATE_ADD('1998-01-02', INTERVAL 31 DAY);

-> '1998-02-02'

mysql> SELECT ADDDATE('1998-01-02', INTERVAL 31 DAY);

*

'1998-02-02'


17.Who is the father of PHP and explain the changes in PHP versions?

Rasmus Lerdorf - father of PHP


18.How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’ using regular expression of PHP?

$s="http://info@abc.com";

$z=preg_split("/@/", $s);

echo $z[1];


19.How can we create a database using PHP and mysql?

mysql_create_db(“database”)


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


21.Functions in IMAP, POP3 AND LDAP?

imap_body — Read the message body

imap_check — Check current mailbox

imap_delete — Mark a message for deletion from current mailbox

imap_mail — Send an email message



22.Suppose your Zend engine supports the mode Then how can u configure your PHP Zend engine to support mode ?


file(filename)-> Reads entire file in an array


In php.ini


Ini_get(include_path):will get the include path


short_open_tag: Allows short tags to be parsed. ( as apposed to
and ?>).

Output Buffering: Allows header line s to be sent after HTML has already been sent to

server.

Max_execution_time: time limit for script execution in seconds.

Variable_order: EGPCS

Register_globals: From 4.2 it is off


23.Shopping cart online validation i.e. how can we configure Paypal, etc.?

24.Draw the architecture of Zend engine?

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

AES_ENCRYPT() and AES_DECRYPT()


26.How can we encrypt the username and password using PHP?

Crypt()


27.What are the features and advantages of object-oriented programming?

28.What are the differences between procedure-oriented languages and object-oriented languages?

29.What is the use of friend function?

30.What are the differences between public, private, protected, static, transient, final and volatile?

31.What are the different types of errors in PHP?

Three are three types of errors 1) Fatal errors 2) Parser errors 3) Startup errors.

Warnings, notices

32.What is the functionality of the function strstr and stristr?

string strstr ( string str1, string str2) this function search the string str1 for the first occurrence of the string str2 and returns the part of the string str1 from the first occurrence of the string str2. This function is case-sensitive and for case-insensitive search use stristr() function.

33.What are the differences between PHP 3 and PHP 4 and PHP 5?

34.How can we convert asp pages to PHP pages?

35.What is the functionality of the function htmlentities?

htmlspecialchars : Convert some special characters to HTML entities (Only the most widley used)

htmlentities : Convert ALL special characters to HTML entities

36.How can we convert the time zones using PHP?

37.What is meant by urlencode and urldocode?

string urlencode(str)

where str contains a string like this “hello world” and the return value will be URL encoded and can be use to append with URLs, normaly used to appned data for GET like someurl.com?var=hello%world

string urldocode(str)

this will simple decode the GET variable’s value

Like it echo (urldecode($_GET_VARS[var])) will o/p “Hello world”

38.How can we register the variables into a session?

session_register($ur_session_var);

39.How can we get the properties (size, type, width, height) of an image using PHP image functions?

getimagesize — Get the size of an image

image_type_to_extension — Get file extension for image type

imagesx — Get image width

imagesy — Get image height

40.How can we get the browser properties using PHP?

41.What is the maximum size of a file that can be uploaded using PHP and how can we change this?

42.How can we increase the execution time of a PHP script?

Use set_time_limit(int) where int is the number of seconds for

execution of the script. If it’s set to 0 it’s unlimited. Default value

is 30.

43.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 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!

44.How can we optimize or increase the speed of a mysql select query?

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

Session_id()

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

Session_unregister()

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

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

49.What is the PHP predefined variable that tells the What types of images that PHP supports?

imagetypes — Return the image types supported by this PHP build

This function returns a bit-field corresponding to the image formats supported by the version of GD linked into PHP. The following bits are returned, IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM. To check for PNG support, for example, do this: Example 1. imagetypes() example

50.How can I know that a variable is a number or not using a JavaScript?

51.List out some tools through which we can draw E-R diagrams for mysql.

52.How can I retrieve values from one database server and store them in other database server using PHP?

53.List out the predefined classes in PHP?

Predefined Classes

Standard Defined Classes

These classes are defined in the standard set of functions included in the PHP build.

a. Directory

The class from which dir() is instantiated.

b.stdClass

2.Ming Defined Classes

These classes are defined in the Ming extension, and will only be available when that extension has either been compiled into PHP or dynamically loaded at runtime.

a.swfshape

b. swffill

c. swfgradient

d. swfbitmap

e. swftext

f. swftextfield

g. swffont

h. swfdisplayitem

i. swfmovie

j. swfbutton

k. swfaction

l. swfmorph

m. swfsprite

3. Oracle 8 Defined Classes

These classes are defined in the Oracle 8 extension, and will only be available when that extension has either been compiled into PHP or dynamically loaded at runtime.

a. OCI-Lob

b. OCI-Collection

4. qtdom Defined Classes

These classes are defined in the qtdom extension, and will only be available when that extension has either been compiled into PHP or dynamically loaded at runtime.

a. QDomDocument

b. QDomNode

54.How can I make a script that can be bilanguage (supports English, German)?

55.What are the difference between abstract class and interface?

56.How can we send mail using JavaScript?

function myfunction(form)

{

tdata=document.myform.tbox1.value;

location=”mailto:dep7abc@leeds.ac.uk?subject=”+tdata+”/MYFORM”;

return true;

}

57. PHP libraries

ADODB

XML RPC

PhpMailer


General


ERRORS IN PHP

Three types of errors are thete

1.

Fatal Error : Run time errors. Execution will be halted.

Making a call to function which does not exist

1.

Warnigns : Run Time warnings. Script Execution will not halted.

Warnings are generally come when using wrong parameter count for functions. Using Undefined variables.

1.

Notices : Run Time Notices. This indicate that the script has encountered something could indicate an error, but could also happen in normal course of running the script.

No comments:

Post a Comment