Last few days I have been working to compile a question and answer set for PHP-MySQL interview questions. So the students can be benefited by them. I will add more as days to come. These questions and answers are compiled from different online resources. If you want to add any question, please add it to the comments section.
Q:1 Who is the father of PHP ?
A:1 Rasmus Lerdorf is known as the father of PHP.
Q:2 Are objects passed by value or by reference?
A:2 Everything is passed by value. In PHP4 it's true, BUT in PHP5 absolutely not - all objects are passed by reference.
Q:3 What is PHP?
A:3 PHP (Hyper text Pre Processor) is a scripting language commonly used for web applications. PHP can be easily embedded in HTML. PHP generally runs on a web server. It is available for free and can be used across a variety of servers, operating systems and platforms.
or
PHP is an open source and widely used general purpose scripting language, designed for web development for producing dynamic web pages. PHP can be embedded into HTML and runs on a web server. The server needs to be configured for processing PHP code and generating web content. PHP can be deployed on most web servers. PHP script can run on almost all platforms.
Q:4 What is the difference between mysql_fetch_object and mysql_fetch_array?
A:4 MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array.
Q:5 Are objects passed by value or by reference?
A:5 Everything is passed by value.
Q:6 What is difference between mysql_connect and mysql_pconnect?
A:6 mysql_connect opens up a database connection every time a page is loaded. mysql_pconnect opens up
a connection, and keeps it open across multiple requests.
mysql_pconnect uses less resources, because it does not need to establish a database connection every
time a page is loaded.
Q:7 How I can get IP address?
A:7 getenv("REMOTE_ADDR");
Q:8 What is CAPTCHA?
A:8 CAPTCHA stands for Completely Automated Public Turing Test to tell Computers and Humans Apart. To prevent spammers from using bots to automatically fill out forms, CAPTCHA programmers will generate an image containing distorted images of a string of numbers and letters. Computers cannot determine what the numbers and letters are from the image but humans have great pattern recognition abilities and will be able to fairly accurately determine the string of numbers and letters. By entering the numbers and letters from the image in the validation field, the application can be fairly assured that there is a human client using it.
Q:9 What is the difference between $x and $$x ?
A:9 $x is simple variable. $$x is reference variable or infact a variable of variable. A variable variable allows us to change the name of a variable dynamically.
<?
$x = "this";
$$x = "is cake";
?>
The $$ is the syntax used in PHP for a variable variable. I can now call the two variables $x and $$x two
ways.
<?
echo "$x ${$x}";
?>
<?
echo "$x $this";
?>
Both of these will return the string "this is cake". Notice that $$x is written as ${$x} in echo. This lets PHP
know that you are using the variable $$x and not $ and $x
Q:10 What is the difference between sizeof($array) and count($array)?
A:10 sizeof($array) - This function is an alias of count()
count($array) - If you just pass a simple variable instead of an array it will return 1.
Soon I Will Post More Questions. If you want to add any question, please add it to the comments section.
No comments:
Post a Comment