Difference between mysql_fetch_array and mysql_fetch_row

Both are same but the difference is that in mysql_fetch_row we can retrieve values by using numeric asccociative example $name=$row[0], but in case of mysql_fetch_array we can retrive value by using table field name and numeric associative. Ex- $name=$row[0] and $name=$row['name'];

How many types of errors in php ?

There are four types of error in php
1. NOTICE
2. WARNING
3. FATAL
4. PARSE

Magic Methods in PHP

With PHP 5 Object Oriented Programming seems to becoming a reality in PHP but we all know that in PHP a variable can take any form depending on the data passed to it. Also PHP automatically creates variable and assigns values to it even is the variables are not defined. But in Object Oriented Programming all the data members/methods needs to be defined. To solve some of these problems in OOPS environment magic methods have been introduced in PHP5.

NOTE ON MAGIC METHODS:
  • Magic methods are the members functions that is available to all the instance of class
  • Magic methods always starts with “__”. Eg. __construct
  • All magic methods needs to be declared as public
  • To use magic method they should be defined within the class or program scope
Various Magic Methods used in PHP 5 are:
  • __construct()
  • __destruct()
  • __set()
  • __get()
  • __call()
  • __toString()
  • __sleep()
  • __wakeup()
  • __isset()
  • __unset()
  • __autoload()
  • __clone()

Objects in php oops

PHP is capable of functioning as an object-oriented programming language (or OOP). As such, it must be able to handle objects. An object is a data type that allows for the storage of not only data but also information on how to process that data. The data elements stored within an object are referred to as its properties, also sometimes called the attributes of the object. The information, or code, describing how to process the data compromises what are called the methods of the object.
Objects have two components to their construction. First, you must declare a class of object. It defines the structure of the object to be constructed. Then you instantiate the object, which means you declare a variable to be of a certain class and assign values to it appropriately.
Another way of looking at objects is that they allow you to create your own data types. You define the data type in the object class, and then you use the data type in instances of that class.
Yes, there is also an is_object() function to test whether a variable is on object instance.

find out the number of parameters passed into function

func_num_args() function returns the number of parameters passed in.

Defining a constant variable in php

Using define() directive, like define ("MYNAME", "Ajay Sharavat"); and to use constant varibale just
type echo MYNAME; or constant("MYNAME");

Difference between include and require

In case of include if the file doesn't exist it will give a warning but the rest of code will execute. But if we are using require then it will through a fatal error and will not execute the code.

Difference between mysql_connect and mysql_pconnect

mysql_connect is a normal mysql connection which opens and closes on each page. While mysql_pconnect is a persistant connection which will be open once and remained open throught the session.
mysql_pconnect does't work on high traffic because we have a limited number of mysql connections.
So using mysql_connect is good to use.

Difference between ereg_replace() and eregi_replace()

ereg_replace() is case sensitive while eregi_replace() is not. For example 'ajay' and 'AjAy' are different for ereg_replace() but same for eregi_replace().