In this article of PHP interview questions we are providing you some frequently asked PHP Interview Questions which will help you to win interview session easily.
Rasmus Lerdorf is known as the father of PHP.
GET and POST
$name is variable where as $$name is reference variable like $name=sonia and $$name=singh so $sonia value is singh.
<?php echo $_SERVER[‘HTTP_USER_AGENT’].”\n\n”; $browser=get_browser(null,true); print_r($browser); ?>
A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.
<?php session_register($ur_session_var); ?>
Register the variable into the session Pass the variable as a cookie Pass the variable as part of the URL
sizeof($array_var) count($array_var)
mysql_create_db();
strstr() returns part of a given string from the first occurrence of a given substring to the end of the string. For example:strstr("user@example.com","@") will return "@example.com". stristr() is idential to strstr() except that it is case insensitive.
CRYPT(), MD5()
move_uploaded_file( string filename, string destination)
The mysql_error() message will tell us what was wrong with our query, similar to the message we would receive at the MySQL console.
CONSTRUCTOR : PHP allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used. DESTRUCTORS : PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence.
There are some defference between GET and POST method 1. GET Method have some limit like only 2Kb data able to send for request but in POST method unlimited data can we send 2. when we use GET method requested data show in url but Not in POST method so POST method is good for send sensetive request
Both include and require used to include a file but when included file not found Include send Warning where as Require send Fatal Error.
The header() function sends a raw HTTP header to a client.We can use herder() function for redirection of pages. It is important to notice that header() must be called before any actual output is seen.
Directory stdClass __PHP_Incomplete_Class exception php_user_filter
In PHP an extended class is always dependent on a single base class,that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'.
Constants in PHP are defined using define() directive, like define("MYCONSTANT", 100);
Just like in C++, put an ampersand in front of it, like $a = &$b;
The output is displayed directly to the browser.
parent::constructor($value)
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
javascript is a client side scripting language, so javascript can make popups and other things happens on someone’s PC. While PHP is server side scripting language so it does every stuff with the server.
unlink() deletes the given file from the file system. unset() makes a variable undefined.
session_id() returns the session id for the current session.
we will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with.
$second = date(“s”);
printf()- Displays a formatted string sprintf()-Saves a formatted string in a variable fprintf() -Prints a formatted string to a file number_format()-Formats numbers as strings
$result = mysql_query($sql, $db_link); $num_rows = mysql_num_rows($result); echo "$num_rows rows found";