Blog Details

Technical Questions In Php :-


1) What is PHP?

  • PHP stands for PHP : Hypertext Preprocessor.
  • PHP is a server side scripting language, like ASP
  • PHP scripts are executed on the server.
  • PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
  • PHP is an open source software (OSS).
  • PHP is free to download and use

2) What is Difference Between $a $$a in php?

  • This is a variable variable. They are evil.
  • $a represents a variable
  • $$a represents a variable with the content of $a

Example 1:

$test = "hello world";
$a = "test";
echo $$a;

output will be hello world

Example 2:

Assuming $a = "foo";$$a will be same as $foo  

3) what is return mysql_query($query) in php ?

  • For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.
  • For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.
  • The returned result resource should be passed to :

                1. mysql_fetch_array()

      • The mysql_fetch_array() function returns a row from a recordset as an associative array and/or a numeric array.

                2. mysql_num_rows()

      • Retrieves the number of rows from a result set. This command is only valid for statements like SELECT or SHOW that return an actual result set.

                3. mysql_affected_rows()

      • to find out how many rows were affected by a DELETE, INSERT, REPLACE, or UPDATE statement.

                4. mysql_fetch_row()

      • The mysql_fetch_row() function returns a row from a recordset as a numeric array.

                5. mysql_fetch_assoc()

      • The mysql_fetch_assoc() function returns a row from a recordset as an associative array.
4) What is the difference between static and Dynamic Web Sites?

Static :

  • In programing language Static is non zero content. We can not change after run the script.
  • Can not change anything in the site/PreDefined/Constant.

Dynamic :

  • Run time change the content of script...!!
  • Can change in run time.

5) How Many Types of the array in PHP ?

  • Indexed arrays

    - Arrays with numeric index


<?php $cars=array("Volvo","BMW","Toyota"); $arrlength=count($cars); for($x=0;$x<$arrlength;$x++) { echo $cars[$x]; echo "<br>"; } ?>
  • Associative arrays

    - Arrays with named keys


<?php $age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43"); echo "Peter is " . $age['Peter'] . " years old."; ?>
  • Multidimensional arrays

    - Arrays containing one or more arrays


<?php $cars = array ( array("Volvo",22,18), array("BMW",15,13), array("Saab",5,2), array("Land Rover",17,15) ); echo $cars[0][0].": In stock: ".$cars[0][1].", sold: ".$cars[0][2].".<br>"; echo $cars[1][0].": In stock: ".$cars[1][1].", sold: ".$cars[1][2].".<br>"; echo $cars[2][0].": In stock: ".$cars[2][1].", sold: ".$cars[2][2].".<br>"; echo $cars[3][0].": In stock: ".$cars[3][1].", sold: ".$cars[3][2].".<br>"; ?>  

6) What is the difference between temporary cookies and persistent cookies?

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

7)  What is the difference between PHP4 and PHP5?

  • PHP4 cannot support oops concepts and Zend engine 1 is used.
  • PHP5 supports oops concepts and Zend engine 2 is used. Error supporting is increased in PHP5. XML and SQLLite will is increased in PHP5.

8) How can we know the number of days between two given dates using PHP? 

$date1 = date('Y-m-d'); $date2 = '2006-07-01'; $days = (strtotime() - strtotime()) / (60 * 60 * 24); echo "Number of days since '2006-07-01': $days";  

9) How can we repair a MySQL table?

  • The syntex for repairing a mysql table is:
  • 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.

10) 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.

11) What is the functionality of the functions STRSTR() and STRISTR()? 

  • string strstr ( string haystack, string needle ) returns part of haystack string from the first occurrence of needle to the end of haystack. This function is case-sensitive.
  • stristr() is idential to strstr() except that it is case insensitive.

12) What is the Difference between count() and strlen() ?

  • count() is for getting the number of elements in an array or object.
  • number
  • strlen() is for getting the number of characters in a string.



Latest posts

Implementing CRUD Operations ¶

<ul> <li>Now comes the fun part. We would like t


<ol> <li><a href="

Creating Model

<ol> <li><a href="

Get Free Quote