Tuesday, October 20, 2009

PHP Interview Questions


1. What does a special set of tags do in PHP? - The output is displayed directly to the browser.
2. What’s the difference between include and require? - It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
3. I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem? - PHP Interpreter treats numbers beginning with 0 as octal. .
4. Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example? - In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like "{$a},000,000 mln dollars", then you definitely need to use the braces.
5. How do you define a constant? - Via define() directive, like define ("MYCONSTANT", 100);
6. How do you pass a variable by value? - Just like in C++, put an ampersand in front of it, like $a = &$b
7. Will comparison of string "10" and integer 11 work in PHP? - Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.
8. When are you supposed to use endif to end the conditional statement? - When the original if was followed by : and then the code block without braces.
9. Explain the ternary conditional operator in PHP? - Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.
10. How do I find out the number of parameters passed into function? - func_num_args() function returns the number of parameters passed in.
11. If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b? - 100, it’s a reference to existing variable.
12. 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.
13. Are objects passed by value or by reference? - Everything is passed by value.
14. How do you call a constructor for a parent class? - parent::constructor($value)
15. What’s the special meaning of __sleep and __wakeup? - __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
16. Why doesn’t the following code print the newline properly?

Because inside the single quotes the \n character is not interpreted as newline, just as a sequence of two characters - \ and n.
17. Would you initialize your strings with single quotes or double quotes? - Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution.
18. How come the code works, but doesn’t for two-dimensional array of mine? - Any time you have an array with more than one dimension, complex parsing syntax is required. print "Contents: {$arr[1][2]}" would’ve worked.
19. What is the difference between characters \023 and \x23? - The first one is octal 23, the second is hex 23.
20. With a heredoc syntax, do I get variable substitution inside the heredoc contents? - Yes.
21. I want to combine two variables together:
$var1 = 'Welcome to ';
$var2 = 'TechInterviews.com';
What will work faster? Code sample 1:
$var 3 = $var1.$var2;
Or code sample 2:
$var3 = "$var1$var2";
Both examples would provide the same result - $var3 equal to "Welcome to TechInterviews.com". However, Code Sample 1 will work significantly faster. Try it out with large sets of data (or via concatenating small sets a million times or so), and you will see that concatenation works significantly faster than variable substitution.
22. For printing out strings, there are echo, print and printf. Explain the differences. –
echo is the most primitive of them, and just outputs the contents following the construct to the screen. print is also a construct (so parentheses are optional when calling it), but it returns TRUE on successful output and FALSE if it was unable to print out the string. However, you can pass multiple parameters to echo, like:

and it will output the string "Welcome to TechInterviews!" print does not take multiple parameters. It is also generally argued that echo is faster, but usually the speed advantage is negligible, and might not be there for future versions of PHP. printf is a function, not a construct, and allows such advantages as formatted output, but it’s the slowest way to print out data out of echo, print and printf.
23. I am writing an application in PHP that outputs a printable version of driving directions. It contains some long sentences, and I am a neat freak, and would like to make sure that no line exceeds 50 characters. How do I accomplish that with PHP? - On large strings that need to be formatted according to some length specifications, use wordwrap() or chunk_split().
24. What’s the output of the ucwords function in this example?
$formatted = ucwords("TECHINTERVIEWS IS COLLECTION OF INTERVIEW QUESTIONS");
print $formatted;
What will be printed is TECHINTERVIEWS IS COLLECTION OF INTERVIEW QUESTIONS.?
ucwords() makes every first letter of every word capital, but it does not lower-case anything else. To avoid this, and get a properly formatted string, it’s worth using strtolower() first.
25. 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.
26. What’s the difference between md5(), crc32() and sha1() crypto on PHP? - The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions.
27. So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()? - Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space. Second, the more secure the crypto is, the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down, if frequent md5() generation is required.

28. How do you match the character ^ at the beginning of the string? - ^\^



29. 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?
Get is an Idompotent method. (Idompotent: The side-effects of N > 0 identical requests is the same as for a single request. The methods GET, HEAD, PUT and DELETE share this property.)”GET” is basically for just getting (retrieving: quering db for data & retriving) data whereas “POST” may involve anything, like storing or updating data, or ordering a product, or sending E-mail. In GET form data is to be encoded (by a browser) into a URL while the latter means that the form data is to appear within a message body. For GET in IE, Maximum URL Length Is 2,083 Characters in Internet Explorer (Q208427) or approximatly 1k.
30. Who is the father of PHP and explain the changes in PHP versions?
Father of PHP is Rasmus Lerdorf
PHP 5.1. Beta
MySQL 5.0
31. 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

32. In how many ways we can retrieve the date in the result set of mysql using PHP?
mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or both
mysql_fetch_assoc — Fetch a result row as an associative array
mysql_fetch_object — Fetch a result row as an object
mysql_fetch_row — Get a result row as an enumerated array
33. 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).
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;
?>
34. What is the difference between $message and $$message?
$message is variable whereas $$message is Dynamic variable.
eg. $user=”bob” is equivalent to $holder=”user”;
$$holder=”bob”;
$message is simple variable.
$$message is reference variable.

35. How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’ using regular expression of PHP?
$ext = strrchr(‘http://info@abc.com’ , ‘@’ );
//output will be abc.com
$exploded[1] should have abc.com
Use the function split split(“@”,”http://info@abc.com”) which returns an array any second element of the returned array will hold the value as abc.com.
echo substr(”http://info@abc.com”,12,19);
36. How can we create a database using PHP and mysql?
mysql_create_db()
37. What are the differences between require and include, include_once?
require_once(),include_once() both the functions include and evalute the specified file only once and if the specified file is opened previous to the present call occurrance, it will not be done again. But require() and include() will do it as many times they are asked to do.
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.
38. Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”?
Yes we can include that many times we want, but here are some things to make sure of:
(including abc.PHP, the file names are case-sensitive)
there shouldnt be any duplicate function names, means there should not be functions or classes or variables with the same name in abc.PHP and makeit.php
39. 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)) ?
Table Types are
· ISAM(Index Sequential Access Method)
· MyISAM
o Static
o Dynamic
o Compress
· Merge
· Heap (Fastest tables because it stores in to the RAM)
· BDB
· InnoDB (Transaction safe table)
When you fire the above create query MySQL will create the Dynamic table.
Ans :
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.

40. 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
41. 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
42. What is meant by nl2br()?
nl2br() inserts html in string
echo nl2br(”god bless \n you”);
output
god bless
you
nl2br
(PHP 3, PHP 4 )
nl2br — Inserts HTML line breaks before all newlines in a string
QUES TION 16
string nl2br ( string string)
Returns string with ‘’ inserted before all newlines.
this will output :
foo isn’t
bar
43. How can we encrypt and decrypt a data present in a mysql table using mysql?
AES_ENCRYPT() and AES_DECRYPT()
AES_ENCRYPT(str,key_str) , AES_DECRYPT(crypt_str,key_str)
44. How can we encrypt the username and password using PHP?
You can encrypt a password with the following
Mysql>SET PASSWORD=PASSWORD(“Password”);
45. What are the different types of errors in PHP?
Three are three types of errors 1) Fatal errors 2) Parser errors 3) Startup errors.
There are three basic types of runtime errors in PHP:
1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although you can change this default 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.
Internally, these variations are represented by twelve different error types
46. 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.
47. 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
48. What is meant by urlencode and urldocode?
1. 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”
49. 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
unlink: is used to delete a file
unset is used to destroy an eralier declared variable
50. How can we register the variables into a session?
session_register($ur_session_var);
51. 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
52. What is the maximum size of a file that can be uploaded using PHP and how can we change this?
In Php.ini file: upload_max_filesize integer
The maximum size of an uploaded file.
When an integer is used, the value is measured in bytes.
53. 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.
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.
54. 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!
55. How can we optimize or increase the speed of a mysql select query?
First, one thing that affects all queries: The more complex permission system setup you have, the more overhead you get.
If you do not have any GRANT statements done, MySQL will optimise the permission checking somewhat. So if you have a very high volume it may be worth the time to avoid grants. Otherwise, more permission check results in a larger overhead.
56. How many ways can we get the value of current session id?
session_id() returns the session id for the current session.
57. How can we destroy the session, how can we unset the variable of a session?
$_SESSION[’name’] = “Chinmay”;
To destroy a session: unset($_SESSION[’name’]);
session_unregister — Unregister a global variable from the current session
session_unset — Free all session variables
58. How can we create and destroy the cookie?
setcookie(”variable”,”value”,”time”);
variable - name of the cookie variable
variable - 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
Reset a cookie by specifying expiry time
Example: setcookie(”test”,$i,time()-3600); // already expired time
Reset a cookie by specifying its name only
setcookie(”test”);
59. How many ways we can pass the variable through the navigation between the pages?
GET or QueryString and POST
60. 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.
61. How can we know the count/number of elements of an array?
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.
62. 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
63. How can I know that a variable is a number or not using a JavaScript?
var myValue =9.8;
if(parseInt(myValue)== myValue)
alert(’Integer’);
else
alert(’Not’);
bool is_numeric ( mixed var)
Returns TRUE if var is a number or a numeric string, FALSE otherwise.
Definition and Usage
The isNaN() function is used to check if a value is not a number.
Syntax
isNaN(number)
Parameter Description
number Required. The value to be tested

64. List out some tools through which we can draw E-R diagrams for mysql.
Case Studio
Smart Draw
65. How can I retrieve values from one database server and store them in other database server using PHP?
For this purpose we have first read the data from one server into session variables. And then connect to other server and simply insert the data into the database
66. List out the predefined classes in PHP?
Predefined Classes
1. 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

67. 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;
}
68. What is meant by PEAR in php?
Ans:-
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”
69. What is the purpose of the following files having extensions 1) frm 2) MYD 3) MYI. What these files contains?
Ans:-
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,




70. 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
71. What is the maximum length of a table name, database name, and fieldname in MySQL?
maximum lenghth of mnames of database, table, columns
database- 64
table -64
columns-64
alias-255
72. How many values can the SET function of MySQL take?
Mysql set can take zero or more values but at the maximum it can take 64 values
73. What are the other commands to know the structure of table using MySQL commands except explain command?
describe table_name;
74. How can we find the number of rows in a table using MySQL?
How can we find the number of rows in a result set using PHP?
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];
and for PHP it cant be more simple
$result = mysql_query($any_valid_sql, $database_link);
$num_rows = mysql_num_rows($result);
echo “$num_rows rows found”;
75. 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()
76. 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 privilages
b) combination of create, drop, select, insert, update and delete etc.
we can grant rights on all databse by usingh *.* 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 user
The generic syntax for revoke is as following
> REVOKE [rights] on [database/s] FROM [username@hostname]
now rights can be as explained above
a) All privilages
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
77. 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 avalue of n-m butes
Set varchar to occupy n bytes and it will take only the required space and will not use the n bytes
eg. name char(10) will waste 5 bytes if we store ‘kumar’, if each char takes a byte
eg. name varchar(10) will just use 5 bytes if we store ‘kumar’, if each char takes a byte. rest 5 bytes will be free.
78. What is the functionality of md5 function in PHP?
string md5(string)
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.
79. How can I load data from a text file into a table?
The mysql provides a LOAD DATA INFILE syntax. U can load data from a file. Gr8 tool but u need to make sure that
a) data is delimited
b) u match the colms and data correctly
dont use w/out first learning the syntax
80. How can we know the number of days between two given dates using MySQL?
Use DATEDIFF()
>SELECT DATEDIFF(NOW(),’1947-08-15′);
will give u the exact no of days India got independence from British.
81. How can we know the number of days between two given dates using PHP?
Simple arithmetic.
$date1 = date(”Y-m-d”);
$date2 = “1947-08-15″;
$days = (strtotime() - strtotime()) / (60 * 60 * 24);
echo ” No of $days we got independence from Britts”;
82. How can we change the name of a column of a table?
How can we change the name and data type of a column of a table?
this will change the name of colm
> ALTER TABLE table_name CHANGE old_colm_name new_colm_name
this will change the name of colm and also the datatype
> ALTER TABLE table_name CHANGE old_colm_name new_colm_name [data type]
83. What are the differences between drop a table and truncate a table?
>DROP TABLE table_name
Will DELETE the table and DATA
>TRUNCATE TABLE table_name
Will DELETE the table DATA not the table definition
84. what is PEAR in PHP
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.
85. 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
86. What is MIME?
MIME is Multipurpose Internet Mail Extensions is an internet standard for the format of e-mail. Howewer browsers also uses MIME standart to transmit files. MIME has a header wich is added to a begining of the data. When browser sees such header it shows the data as it would be a file (for example image)
some mimes:
audio/x-ms-wmp
image/png
aplication/x-shockwave-flash



87. 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().
88. What are the differences between MySQL_fetch_array(), MySQL_fetch_object(), MySQL_fetch_row()?
Ans:- MySQL_fetch_array()->Fetch a result row as an associative array,numeric array.
MySQL_fetch_object()->Fetch a result row as an object.
MySQL_fetch_row()->Fetch a result set as an array().
89. If we login more than one browser window at the same time with same user and after that we close one window then is the session is exist to other window or not.And if yes then why? or if no then why?
session depends on browser. if browser is closed then session is lost. the session data will be deleted after session time out. if connection is lost and u recreate connection, then also sesssion will continue in the browser.
90. What are the database files stored in system?
data’s are stored in name.Myd
table Structure are name.$frm
Index tables are name.myi
91. what is the difference between groupby and order by in mysql?
Ans: Group by which is used to sort a table interms of colums
order by which is used to index a table by colum value
92. What are the differences between MySQL_fetch_array(), MySQL_fetch_object(), MySQL_fetch_row()?
The difference between mysql_fetch_row() and mysql_fetch_array() is that the first returns the results in a numeric array ($row[0], $row[1] etc), while the latter returns a the results an array containing both numeric and associative keys ($row[”name”], $row[”email”] etc). mysql_fetch_object() returns an object ($row->name, $row->email etc).

No comments:

Post a Comment