Вы находитесь на странице: 1из 41

What is PHP?

Latest Answer - PHP (Hyper text Pre Processor) is a scripting language commonly used for web applications............. Read answer
What Is a Session in PHP?

Latest Answer - A PHP session is no different from a normal session. It can be used to store information on the server for future use............. Read answer
Explain the difference between $message and $$message?

Latest Answer - $message is used to store variable data. $$message can be used to store variable of a variable............. Read answer
How to set cookies in PHP?

Latest Answer - Cookies are often used to track user information............. Read answer
What is the difference between include and require?

Latest Answer - Require () and include () are the same with respect to handling failures............. Read answer
What is urlencode and urldecode?

Latest Answer - Urlencode can be used to encode a string that can be used in a url............. Read answer
What are the different types of errors in PHP?

Latest Answer - Different types of errors are............ Read answer


Explain how to submit form without a submit button.

Latest Answer - A form data can be posted or submitted without the button in the following ways:............ Read answer

What are the functions for IMAP?

Latest Answer - IMAP is used for communicate with mail servers. It has a number of functions............. Read answer
How can we increase the execution time of a php script?

Latest Answer - Default time allowed for the PHP scripts to execute is 30s defined in the php.ini file............. Read answer
What is Type juggle in php?

Latest Answer - Type Juggling means dealing with a variable type. In PHP a variables type............ Read answer
What is the difference between mysql_fetch_object and mysql_fetch_array?

Latest Answer - Mysql_fetch_object returns the result from the database as objects while............ Read answer
What is the difference between the functions unlink and unset?

Latest Answer - Unlink is a function for file system handling which deletes a file............. Read answer
What is Joomla in PHP?

Latest Answer - Joomla is an open source content management system............. Read answer
What is zend engine?

Latest Answer - Zend Engine is used internally by PHP as a complier and runtime engine............. Read answer
What is the difference between Split and Explode?

Latest Answer - Both the functions are used to Split a string. However, Split is used to split............ Read answer
What is the difference between echo and print statement?

Latest Answer - Echo can accept multiple expressions while print cannot............. Read answer
What is CAPTCHA?

Latest Answer - CAPTCHA is a test to determine if the user using the system............ Read answer
What is difference between developing website using Java and PHP?

Latest Answer - In order to make interactive pages, java uses JSP (Java Server pages)............. Read answer
How do you create sub domains using PHP?

Latest Answer - Wild card domains can be used. Sub domains can be created by first creating............ Read answer
How to upload files using PHP?

Latest Answer - Files can be uploaded in PHP by using the tag type=file............. Read answer< /A>
What is the difference between Notify URL and Return URL?

Latest Answer - Notify URL and Return URL is used in Paypal Payment Gateway integration............. Read answer
Describe functions STRSTR() and STRISTR.

Latest Answer - Both the functions are used to find the first occurrence of a string............. Read answer

What are the various methods to pass data from one web page to another web page?

Latest Answer - Different methods to pass data from one web page to another:............ Read answer
1 ) What will you use to initialize a string ? ie with single quotes or double quotes ? Ans: Unlike the double-quoted syntaxes, variables and escape sequences for special characters will not be expanded when they occur in single quoted strings. As in single quoted strings, escaping any other character will result in the backslash being printed too. Before PHP 5.1.1, the backslash in \{$var}had not been printed. The most important feature of double-quoted strings is the fact that variable names will be expanded. 2 ) You have a string hi all, I said hello . You want to replace the occourence of hi with hello and hello with hi . What will you do ? Ans: $rawstring= "hi all, I said hello"; $placeholders = array('hi', 'hello'') $malevals = array('hello', hi'); $malestr = str_replace($placeholders, $malevals, $rawstring); echo $malestr ; --ereg() - Regular expression match eregi() - Case insensitive regular expression match eregi_replace() - Replace regular expression case insensitive str_replace() - Replace all occurrences of the search string with the replacement string preg_match() - Perform a regular expression match ============== more details: http://php.net/manual/en/function.ereg-replace.php http://www.tizag.com/phpT/php-string-str_replace.php 3 ) Whats the difference between PHP4 and PHP5 ? Ans: The new OOP features in PHP5 is probably the one thing that everyone knows for sure about. Out of all the new features, these are the ones that are talked about most!

1. Passed by Reference 2. Visibility[public, protected, private] 3. Unified Constructors and Destructors 4. The __autoload Function ===========

more details: http://tycoontalk.freelancer.com/php-forum/78717-differences-between-php4-andphp5.html 4 ) Whats all added in PHP 5.3 ? Ans: PHP 5.3.0 offers a wide range of new features:

Support for namespaces has been added. Support for Late Static Bindings has been added. Support for jump labels (limited goto) has been added. Support for native Closures (Lambda/Anonymous functions) has been added. There are two new magic methods, __callStatic and __invoke. Nowdoc syntax is now supported, similar to Heredoc syntax, but with single quotes. It is now possible to use Heredocs to initialize static variables and class properties/constants. Heredocs may now be declared using double quotes, complementing the Nowdoc syntax. Constants can now be declared outside a class using the const keyword. The ternary operator now has a shorthand form: ?:. The HTTP stream wrapper now considers all status codes from 200 to 399 to be successful. Dynamic access to static methods is now possible. Exceptions can now be nested. A garbage collector for circular references has been added, and is enabled by default. The mail() function now supports logging of sent email.

======== more details: http://php.net/manual/en/migration53.new-features.php 5 ) Whats Name spacing ? Ans: In the PHP world, namespaces are designed to solve two problems that authors of libraries and applications encounter when creating re-usable code elements such as classes or functions: 1. Name collisions between code you create, and internal PHP classes/functions/constants or third-party classes/functions/constants. 2. Ability to alias (or shorten) Extra_Long_Names designed to alleviate the first problem, improving readability of source code. PHP Namespaces provide a way in which to group related classes, interfaces, functions and constants.

6 ) What are the types of inheritance PHP supports ? Ans: Similar to Java, PHP supports single inheritance. There is no multiple inheritance in php. Single inheritance means a class can extend only one parent class. PHP also has interfaces which can be implemented if bunch of classes need to have similar functionality. An interface can be created containing methods with empty body. Implementing classes then must provide body to those methods. When a class implements an interface, it is signing up a contract that it will provide implementation to methods declared in that interface. 7 ) What do you mean by an Abstract class and Interface ? Ans: Depending on the context, an interface class is either a class of the interface layer or a class whose purpose is to create a contract between a caller and an implementation (usually by providing only purely virtual functions). An abstract class is a class that has at least one purely virtual function. Abstract classes can contain abstract and concrete methods. Abstract classes cannot be instantiated directly i.e. we cannot call the constructor of an abstract class directly nor we can create an instance of an abstract class A static class is a class that has only static member variables and static member functions. ====== more details: http://www.interview-questions-java.com/abstract-class-interface.htm 8 ) When a file is uploaded to the sever how can you check whether its uploaded or not ? Ans: (PHP 4 >= 4.0.3, PHP 5) is_uploaded_file Tells whether the file was uploaded via HTTP POST. is_uploaded_file($_FILES['userfile']['tmp_name']); Returns TRUE on success or FALSE on failure. 9 ) How will you move the uploaded file to another location of server ? Ans: move_uploaded_file Moves an uploaded file to a new location. This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.

10 ) What are the things that need to be checked before uploading a file ? Ans: Check picture file type and size before file upload.. more details: http://php.net/manual/en/features.file-upload.php 11 ) How will you connect mysql ? Ans: Here u can get Click Here 12 ) Does PHP supports PDF creation ? Ans: The PDF functions in PHP can create PDF files using the PDFlib library which was initially created by Thomas Merz and is now maintained by PDFlib GmbH. Starting with PHP 4.0.5, the PHP extension for PDFlib is officially supported by PDFlib GmbH. This means that all the functions described in the PDFlib Reference Manual are supported by PHP 4 with exactly the same meaning and the same parameters. 13 ) What are the storage types in MySQL ? Ans: 13.1. The MyISAM Storage Engine[default engine] 13.2. The InnoDB Storage Engine 13.3. The MERGE Storage Engine 13.4. The MEMORY (HEAP) Storage Engine 13.5. The BDB (BerkeleyDB) Storage Engine 13.6. The EXAMPLE Storage Engine 13.7. The FEDERATED Storage Engine 13.8. The ARCHIVE Storage Engine 13.9. The CSV Storage Engine 13.10. The BLACKHOLE Storage Engine more details http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html

14 ) What is the difference between InnoDb and MyISAM ? Ans:


The big difference between MySQL Table Type MyISAM and InnoDB is that InnoDB supports transaction InnoDB supports some newer features: Transactions, row-level locking, foreign keys InnoDB is for high volume, high performance

15 ) Does MyISAM supports relations ? Ans: InnoDB has foreign keys and relationship contraints while MyISAM does not.

more details http://www.kavoir.com/2009/09/mysql-engines-innodb-vs-myisam-a-comparison-of-pros-andcons.html

16 ) Whats indexing ? Ans: A database index is a data structure that improves the speed of data retrieval operations on a database table at the cost of slower writes and increased storage space. 17 ) MySQL is case sensitive or case insensitive ? Ans: SQL itself isn't case sensitive, but it can be on searching data, all depends on the table collation settings. MySQL syntax is not case sensitive, you can write SELECT * FROM table WHERE ... or select * from table where... or SeLEct * FroM table WHerE or whatever else you want.

On select queries you can search for case sensitive fields values, in example if you want to find "text" inside a field but not "TEXT", "Text".... you can use

SELECT * FROM table WHERE binary(fieldname)='text'; 18 ) You have a table say user with field name and datas Lokam , loker , lover , Lough , Lost , Enough , Elephant etc . Write a query which gives all the terms Lokam , loker , lover , Lough and Lost . Ans: 19 ) Now you want to select only the loker , lover . What will you add to get this result ? Ans:

20 ) Let there is table user with name and marks . How will you select the second largest number from this table ? For eg let the datas are hari 23 , jenson 10 , ruby 20 , rijith 10 . You want to select 20 from this. Ans: 21 ) What are the different types of JOINS ? Ans: A join combines records from two or more tables in a relational database. In the Structured Query Language (SQL), there are two types of joins: "inner" and "outer". Outer joins are subdivided further into left outer joins, right outer joins, and full outer joins. Inner join This is the default join method if nothing else is specified. An inner join essentially finds the intersection between the two tables. The join takes all the records from table A and finds the matching record(s) from table B. If no match is found, the record from A is not included in the results. If multiple results are found in B that match the predicate then one row will be returned for each (the values from A will be repeated). Special care must be taken when joining tables on columns that can be NULL since NULL values will never match each other Left outer join A left outer join is very different from an inner join. Instead of limiting results to those in both tables, it limits results to those in the "left" table (A). This means that if the ON clause matches 0 records in B, a row in the result will still be returnedbut with NULL values for each column from B. Right outer join A right outer join is much like a left outer join, except that the tables are reversed. Every record from the right side, B, will be returned, and NULL values will be returned for those that have no matching record in A. Full outer join Full outer joins are the combination of left and right outer joins. These joins will show records from both tables, and fill in NULLs for missing matches on either side 22 ) What is LEFT , RIGHT , INNER joins ? Ans: Here You Can get ful details.. http://www.w3schools.com/sql/sql_join_inner.asp http://www.w3schools.com/sql/sql_join_left.asp http://www.w3schools.com/sql/sql_join_right.asp 23 ) Have you used Triggers ? What is it ? Ans: A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database.

The trigger is mostly used for keeping the integrity of the information on the database. For example, when a new record (representing a new worker) is added to the employees table, new records should be created also in the tables of the taxes, vacations, and salaries. 24 ) What is Views in MySQL ? Ans: A database View is known as a "virtual table" which allows you to query the data in it. Understanding Database View and using it correctly is crucial. MySQL views are essentially a way to package up SELECT statements into re-usable virtual tables whereby the data can be retrieved simply by referencing the view, rather than having to repeat the associated SELECT statement. 25 ) Have you written procedures ? How can you write a procedure in MySQL ? Ans: Here You Can get more details about procedure http://www.9lessons.info/2010/07/stored-procedure-lesson.html http://forge.mysql.com/wiki/MySQL_Internals_Procedure http://stackoverflow.com/questions/2846516/how-to-write-a-stored-procedure-usingphpmyadmin-and-how-to-use-it-through-php 26 ) How can you call a mysql procedure from PHP ? Ans: Read all links of ans 25. 27 ) What is MVC ? ( If you are strong in any frameworks , then questions from that can also be hit, dont make it a miss rate ) Ans: Here U can get details http://www.jcorporate.com/expresso/doc/edg/edg_WhatIsMVC.html http://whatis.techtarget.com/definition/model-view-controller-MVC http://www.codinghorror.com/blog/2008/05/understanding-model-view-controller.html 28 ) Does PHP has an XML library ? Is it comming as default ? Ans: Here U can get details. read all w3school PHP XML Links[Total:3]. http://www.w3schools.com/php/php_xml_simplexml.asp http://www.php.net/manual/en/book.simplexml.php 29 ) Whats SOAP ? Ans: SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks.

It relies on Extensible Markup Language (XML) for its message format, and usually relies on other Application Layer protocols, most notably Hypertext Transfer Protocol(HTTP) and Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission. SOAP can form the foundation layer of a web services protocol stack, providing a basic messaging framework upon which web services can be built.

30 ) Whats is XSS attack ? Ans: Cross-site scripting (XSS) is a type of computer security vulnerability typically found in Web applications that enables attackers to inject client-side script into Web pages viewed by other users. A cross-site scripting vulnerability may be used by attackers to bypass access controls such as the same origin policy. 31 ) Whats the difference between htmlspecialchars and htmlentities ? Ans: Details Here http://stackoverflow.com/questions/46483/htmlentities-vs-htmlspecialchars http://in.answers.yahoo.com/question/index?qid=20100525200639AAUHgFO http://www.wallpaperama.com/forums/php-htmlentities-vs-htmlspecialchars-differences-phpfunctions-t5783.html 32 ) What is Session and Cookie ? Ans: If u want this ans then please forget about php. http://www.allaboutcookies.org/cookies/session-cookies-used-for.html/ http://www.tuxradar.com/practicalphp/10/1/0 33 ) Whats the difference between session_register and $_SESSION ? Ans: The very first main and simple difference is that session_register function returns boolean value and $_SESSION returns string value. The second will be session_register function doesn't work if register_global is disabled. But whereas $_SESSION works in both case whether register_global is disabled or enabled. So using $_SESSION for session variable manipulation is more appropriate. 34 ) What is magic quotes ? Is it on or off by default in PHP 5 ? Ans: Magic Quotes is a process that automagically escapes incoming data to the PHP script. It's preferred to code with magic quotes off and to instead escape the data at runtime, as needed. Magic Quotes are depreciated and going to be removed in PHP6. 35 ) What does __sleep and __wake do ? Ans: Here Details http://www.sunilb.com/php/php5-oops-tutorial-magic-methods-__sleep-and-__wakeup http://www.phpinterviewquestion.com/php-questions/what%E2%80%99s-__sleep-and__wakeup-in-php

36 ) Can you submit a form without a submit button ? Ans: You can submit a form without a submit button, but it relies on javascript, which is a bad thing. How will you keep your pages working for those without javascript enabled?

Anyway, to submit the first form on your page, you can use something like this: on link onclick="document.forms[0].submit();" submit

37 ) How can you set a cookie to expire after 30 minutes or so ? Ans: 30 minutes is 30 * 60 * 1000 miliseconds. Add that to the current date to specify an expiration date 30 minutes in the future.
var date = new Date(); date.setTime(date.getTime() + (30 * 60 * 1000)); $.cookie("example", "foo", { expires: date }); and for session>> if(isSet($_SESSION['started'])){ if((mktime() - $_SESSION['started'] - 60*30) > 0){ //logout, destroy session etc } }else{ $_SESSION['started'] = mktime(); }

Q1.Can we write windows like applications in PHP. Ans : Yes using PHP-GTK on linux and WinBinder on windows. Q2.What difference does it make when I declare variables with $ and $ in prefix. Ans: $x = "Lion"; $$x = "Zebra"; echo $Lion; would display "Zebra" Use : creating runtime variables Q3.What is the difference between strpos and stripos function? Ans: strpos is case sensitive search, and stripos is case insensitive search Q4.What are the ways by which we can find out if a variable has been declared? Ans: isset or empty language constructs Q5.What is "global" and how to use it? Ans: variables declared outside the functions can be used inside the function using global keyword

Q6.What is the difference between echo and print Ans: echo can take more than one parameter for displaying. print cannot take more than one e.g echo 'This', 'That' //is valid print 'This', 'That' //is invalid print returns 1 always. echo cannot be used to return anything $ret = print "Abcd" //valid $ret = echo "Abcd" //invalid Q7.What are predefined variables in php, give some examples. Ans: PHP provides an additional set of predefined arrays containing variables from the web server (if applicable), the environment, and user input. These new arrays are rather special in that they are automatically global [ Resource Link : http://in.php.net/manual/en/language.variables.predefined.php ] e.g., $_SERVER, $_REQUEST, $_POST, $_GET, $_ENV, $_COOKIE, $_FILES, $_SESSION, $GLOBALS, $php_errormsg, $http_response_header Q8.Give examples of predefined classes in PHP, and specify the use of anyone of them. Ans: stdClass, Exception,_PHP_Incomplete_Class, php_user_filter, Directory Exception : for exception handling Directory: dir class Q9.Declaring a class. Ans: public/private/protected [static] class <classname> extends <baseclassname>{ public $x; public function method_a() { } } Q10.How can we instantiate a class with default values. Ans: Write a function with the same name as class and assign values to the vars. E.g.: class myclass { private $var1, $var2; function myclass() { $this->var1 = "Demo"; $this->var2 = "Disabled"; } function __get($x) { return $this->$x;

} } $m = new myclass(); echo $m->var1 . " Vars " . $m->var2; Q11.Abstraction, interfaces explain the main difference. Ans: a) Abstract classes cannot be instantiated, b) They start with keyword abstract before the class name, c) One can force the methods to be declared in the inheriting class by creating abstract functions d) only abstract class can have abstract methods eg. abstract class a { abstract function b(); public function c() { echo "Can be used as it is"; } } class m extends a { public function b() { echo "Defined function b"; } } $tClass = new m(); $tClass->b(); $tClass->c();

Q12.Interface classes only provide the skeleton of the class that the inheriting class must implement. Eg. interface Person{ public function myFunc(); } class Employee implements Person { public function myFunc() { echo "Implemented"; } }

$tClass = new Employee(); $tClass->myFunc(); Q13.What are magic methods? Ans: Functionalities like serializing, converting objects to string, getting setting values without explicit get and set methods for the variables etc, are magic functionality. PHP defines methods with names starting with __(double underscore). Eg. __get, __set, __construct, __destruct, __set, __isset, __unset, __sleep, __wakeup, __toString, __clone, __autoload, __set_state [ Resource Link : http://in.php.net/manual/en/language.oop5.magic.php ]

Q14.What does function `eval` do? Ans: Evaluate a string as PHP code; Eg. eval('echo "This would be printed"'); Q15.What is the method by which PHP converts datatype of a given variable. Ans: settype() $a = "10"; // $a is string settype($a,"integer"); // $a is integer Q.Can we change php.ini settings at the runtime, and how? Ans : Yes, using ini_set(); Q16.What is the difference between sort(), assort() and ksort? Under what circumstances would you use each of these? Ans: Sorts an array, sorts an array and maintains index association, Sorts an array by key Simple sort (sorts on values) Simple sort after sorting the array (lets assume size of array is 10) rearranges the index, if we want to access element at index[5], using a simple sort an element value would have changed, but in assort the value is still held by index 5 though its position in the array may be 10th. Ksort sorts the array by key and maintains the key to data correlations

Q17.What is the difference between foo() & @foo()? Ans: if an error occurs calling foo() would show up the error on the screen, whereas, @foo() would suppress the error because @ is a error control operator. Q18.What is the difference between mysql_fetch_row() and mysql_fetch_array() and mysql_fetch_object? Ans: mysql_fetch_row() fetches a row as an enumerated array mysql_fetch_array() - Fetch a result row as an associative array, a numeric array, or both mysql_fetch_object - Fetch a result row as an object

Q19.What is the difference between include & include_once? include & require? Ans: include_once includes the script only once if it is already included in the execution of the script Include includes the script everytime the include is encountered in the code Require is identical to include except that it results in fatal error when file is not present in the include_path. Q20.What type of inheritance PHP supports? Ans: An object can inherit only from one base class. Multiple inheritance is not supported in PHP. Q21.How can we call an object's method by using the variable functions? Ans: If MyClass contains function myFunction() $foo = new MyClass(); $var = "myFunction"; $c->$var(); [ Resource Link : http://in.php.net/manual/en/functions.variable-functions.php ] Ajax, Cross site scripting (JavaScript). Q22.What is the use of AJAX? Ans: If a page contains form that needs to be updated constantly based on runtime values, a javascript code constantly sends user input to the system and displays the results from the server, without refreshing the whole page. Q23.What is cross site scripting, and how to avoid it? Ans: Injecting a javascript code in the response of a form that is capable of calling and executing scripts from other site. Occurs when variables holding form values are not cleaned with html code escaping functions. Clean the variables before storing or before display. Recommendation is to display the code clean and store the value as it is, unless its specified otherwise. MYSQL. Q1.What is a join, what types of join are supported in MySQL. Ans: A join joins two table in such a way that all or partial records are selected from both the table based on join criteria. Joins supported in mysql are : [INNER | CROSS] JOIN STRAIGHT_JOIN

LEFT [OUTER] JOIN NATURAL [LEFT [OUTER]] JOIN RIGHT [OUTER] JOIN NATURAL [RIGHT [OUTER]] JOIN

Q2.In MySQL, what table type is required for foreign keys to work? Ans: innoDB Q3.How does full text search work. Ans: A table must be a myISAM table Table must have char varchar and text columns FULLTEXT index must be created at the time of creation of table Q4.What is the use of files .frm, .MYD, .MYI Ans: frm files store the table definition MYD files store the data MYI files store the index Q5.What is maximum size of a database in MySQL? Ans: 65+GB / table / [ limited by the OS] Q6.How many columns can exist in a mySql table? Ans: 4096 colums Q7.What is the maximum size of a row in a mysql table? Ans: 65,535 not including blobs (as these are stored separately) Q8. What would you use if you have a choice Natural [left] join or inner join or left join with using clause? Ans: The NATURAL [LEFT] JOIN of two tables is defined to be semantically equivalent to an INNER JOIN or a LEFT JOIN with a USING clause that names all columns that exist in both tables

PHP-MySQL Interview Question


Last few days I have been working to compile a question and answer set for PHP-MySQL interview questions. There are roughly 150 questions and i will be adding more as days to come. These questions and answers are compiled from different online resources. I am planning to make it a PDF version so that people download it and go through it offline. I hope i will be able to finish it soon.

NB: If you want to add any question, please add it to the comments section. I want to make it a big repository. Here is the first set of 80 Questions and answer.
Q:1

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?

A:1

When to use GET or POST


The HTML 2.0 specification says, in section Form Submission (and the HTML 4.0 specification repeats this with minor stylistic changes): >If the processing of a form is idempotent (i.e. it has no lasting observable effect on the state of the world), then the form method should be GET. Many database searches have no visible side-effects and make ideal applications of query forms. >If the service associated with the processing of a form has side effects (for example, modification of a database or subscription to a service), the method should be POST.

How the form data is transmitted?


quotation from the HTML 4.0 specification > If the method is get -, the user agent takes the value of action, appends a ? to it, then appends the form data set, encoded using the application/x-www-form-urlencoded content type. The user agent then traverses the link to this URI. In this scenario, form data are restricted to ASCII codes. > If the method is post , the user agent conducts an HTTP post transaction using the value of the action attribute and a message created according to the content type specified by the enctype attribute.

Quote from CGI FAQ


Firstly, the the HTTP protocol specifies differing usages for the two methods. GET requests should always be idempotent on the server. This means that whereas one GET request might (rarely) change some state on the Server, two or more identical requests will have no further effect. This is a theoretical point which is also good advice in practice. If a user hits reload on his/her browser, an identical request will be sent to the server, potentially resulting in two identical database or guestbook entries, counter increments, etc. Browsers may reload a GET URL automatically, particularly if cacheing is disabled (as is usually the case with CGI output), but will typically prompt the user before re-submitting a POST request. This means youre far less likely to

get inadvertently-repeated entries from POST. GET is (in theory) the preferred method for idempotent operations, such as querying a database, though it matters little if youre using a form. There is a further practical constraint that many systems have built-in limits to the length of a GET request they can handle: when the total size of a request (URL+params) approaches or exceeds 1Kb, you are well-advised to use POST in any case. I would prefer POST when I dont want the status to be change when user resubmits. And GET when it does not matter.

Q:2 A:2

Who is the father of PHP and explain the changes in PHP versions? Rasmus Lerdorf is known as the father of PHP.PHP/FI 2.0 is an early and no longer supported version of PHP. PHP 3 is the successor to PHP/FI 2.0 and is a lot nicer. PHP 4 is the current generation of PHP, which uses the Zend engine under the hood. PHP 5 uses Zend engine 2 which, among other things, offers many additionalOOP features

Q:3 A:3

How can we submit a form without a submit button? The main idea behind this is to use Java script submit() function in order to submit the form without explicitly clicking any submit button. You can attach the document.formname.submit() method to onclick, onchange events of different inputs and perform the form submission. you can even built a timer function where you can automatically submit the form after xx seconds once the loading is done (can be seen in online test sites).

Q:4

In how many ways we can retrieve the data in the result set of MySQL using PHP? You can do it by 4 Ways1. mysql_fetch_row. 2. mysql_fetch_array 3. mysql_fetch_object 4. mysql_fetch_assoc

A:4

Q:5

What is the difference between mysql_fetch_object and mysql_fetch_array?

A:5

mysql_fetch_object() is similar tomysql_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).

Q:6 A:6

What is the difference between $message and $$message? It is a classic example of PHPs variable variables. take the following example.$message = Mizan;$$message = is a moderator of PHPXperts.;$message is a simple PHP variable that we are used to. But the $$message is not a very familiar face. It creates a variable name $mizan with the value is a moderator of PHPXperts. assigned. break it like this${$message} => $mizanSometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically.

Q:7

How can we extract string abc.com from a string http://info@abc.com using regular expression of PHP? preg_match(/^http:\/\/.+@(.+)$/,http://info@abc.com&#8217;,$found); echo $found[1];

A:7

Q:8 A:8

How can we create a database using PHP and MySQL? We can create MySQL database with the use of mysql_create_db(Database Name)

Q:9

What are the differences between require and include, include_once and require_once? The include() statement includes and evaluates the specified file.The documentation below also applies to require(). The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include()

A:9

statement, with the only difference being that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.include_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc. require_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.

Q:10 Can we use include (abc.PHP) two times in a PHP page makeit.PHP? A:10 Yes we can use include() more than one time in any page though it is not a very good practice.

Q:11 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)) ? A:11 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 and as a result if we do not specify the table name explicitly it will be assigned to the default engine.

Q:12 Functions in IMAP, POP3 AND LDAP? A:12 You can find these specific information in PHP Manual.

Q:13 How can I execute a PHP script using command line?

A:13 As of version 4.3.0, PHP supports a new SAPI type (Server Application Programming Interface) named CLI which means Command Line Interface. Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, php myScript.php, assuming php is the command to invoke the CLI program. Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.

Q:14 Suppose your Zend engine supports the mode <? ?> Then how can u configure your PHP Zend engine to support <?PHP ?> mode ? A:14 In php.ini file: set short_open_tag=on to make PHP support

Q:15 Shopping cart online validation i.e. how can we configure Paypal, etc.? A:15 We can find the detail documentation about different paypal integration process at the following site

PayPal PHP SDK : http://www.paypaldev.org

Q:16 What is meant by nl2br()? A:16 Inserts HTML line breaks (<BR />) before all newlines in a string string nl2br (string); Returns string with inserted before all newlines. For example: echo nl2br(god bless\n you) will output god bless <br /> you to your browser.

Q:17 Draw the architecture of Zend engine? A:17 The Zend Engine is the internal compiler and runtime engine used by PHP4. Developed by Zeev Suraski and Andi Gutmans, the Zend Engine is an abbreviation of their names. In the early days of PHP4, it worked as follows: The PHP script was loaded by the Zend Engine and compiled into Zend opcode. Opcodes, short for operation codes, are low level binary instructions. Then the opcode was executed and the HTML generated sent to the client. The opcode was flushed from memory after execution.Today, there are a

multitude of products and techniques to help you speed up this process. In the following diagram, we show the how modern PHP scripts work; all the shaded boxes are optional. PHP Scripts are loaded into memory and compiled into Zend opcodes.

Q:18 What are the current versions of apache, PHP, and MySQL? A:18 As of February, 2007 the current versions arePHP: php5.2.1 MySQL: MySQL 5.2 Apache: Apache 2.2.4Note: visit www.php.net,

http://dev.mysql.com/downloads/mysql/, www.apache.org to get current versions.

Q:19 What are the reasons for selecting lamp (Linux, apache, MySQL, PHP) instead of combination of other software programs, servers and operating systems? A:19 All of those are open source resource. Security of Linux is very very more than windows. Apache is a better server that IIS both in functionality and security. MySQL is world most popular open source database. PHP is more faster that asp or any other scripting language.

Q:20 How can we encrypt and decrypt a data present in a MySQL table using MySQL? A:20 AES_ENCRYPT () and AES_DECRYPT ()

Q:21 How can we encrypt the username and password using PHP? A:21 The functions in this section perform encryption and decryption, and compression and uncompression:

encryption AES_ENCRYT()

decryption AES_DECRYPT()

ENCODE() DES_ENCRYPT() ENCRYPT() MD5()

DECODE() DES_DECRYPT() Not available Not available

OLD_PASSWORD() Not available PASSWORD() SHA() or SHA1() Not available Not available Not available UNCOMPRESSED_LENGTH()

Q:22 What are the features and advantages of object-oriented programming? A:22 One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real world than is procedural programming. It allows for more complicated and flexible interactions. OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition patterns. For some systems, an OO approach can speed development time since many objects are standard across systems and can be reused. Components that manage dates, shipping, shopping carts, etc. can be purchased and easily modified for a specific system

Q:23 What are the differences between procedure-oriented languages and object-oriented languages? A:23 Traditional programming has the following characteristics:Functions are written sequentially, so that a change in programming can affect any code that follows it. If a function is used multiple times in a system (i.e., a piece of code that manages the date), it is often simply cut and pasted into each program (i.e., a change log, order function, fulfillment system, etc). If a date change is needed (i.e., Y2K when the code needed to be changed to handle four numerical digits instead of two), all these pieces of code must be found, modified, and tested. Code (sequences of computer instructions) and data (information on which the instructions operates on) are kept separate. Multiple sets of code can access and modify one set of data. One set of code may rely on data

in multiple places. Multiple sets of code and data are required to work together. Changes made to any of the code sets and data sets can cause problems through out the system.Object-Oriented programming takes a radically different approach:Code and data are merged into one indivisible item an object (the term component has also been used to describe an object.) An object is an abstraction of a set of real-world things (for example, an object may be created around date) The object would contain all information and functionality for that thing (A date object it may contain labels like January, February, Tuesday, Wednesday. It may contain functionality that manages leap years, determines if it is a business day or a holiday, etc., See Fig. 1). Ideally, information about a particular thing should reside in only one place in a system. The information within an object is encapsulated (or hidden) from the rest of the system. A system is composed of multiple objects (i.e., date function, reports, order processing, etc., See Fig 2). When one object needs information from another object, a request is sent asking for specific information. (for example, a report object may need to know what todays date is and will send a request to the date object) These requests are called messages and each object has an interface that manages messages. OO programming languages include features such as class, instance, inheritance, and polymorphism that increase the power and flexibility of an object.

Q:24 What is the use of friend function? A:24 Sometimes a function is best shared among a number of different classes. Such functions can be declared either as member functions of one class or as global functions. In either case they can be set to be friends of other classes, by using a friend specifier in the class that is admitting them. Such functions can use all attributes of the class which names them as a friend, as if they were themselves members of that class. A friend declaration is essentially a prototype for a member function, but instead of requiring an implementation with the name of that class attached by the double colon syntax, a global function or member function of another class provides the match.

Q:25 What are the differences between public, private, protected, static, transient, final and volatile? A:25 Public: Public declared items can be accessed everywhere. Protected: Protected limits access to inherited and parent classes (and to the class that defines the item). Private: Private limits visibility only to the class that defines the item. Static: A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope. Final: Final keyword prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended.

transient: A transient variable is a variable that may not be serialized. volatile: a variable that might be concurrently modified by multiple threads should be declared volatile. Variables declared to be volatile will not be optimized by the compiler because their value can change at any time.

Q:26 What are the different types of errors in PHP? A:26 Three are three types of errors: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, as you will see, you can change this default behavior.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 PHPs default behavior is to display them to the user when they take place.

Q:27 What is the functionality of the function strstr and stristr? A:27 strstr: Returns part of haystack string from the first occurrence of needle to the end of haystack.If needle is not found, returns FALSE. If needle is not a string, it is converted to an integer and applied as the ordinal value of a character. This function is case-sensitive. For case-insensitive searches, use stristr().

Q:28 What are the differences between PHP 3 and PHP 4 and PHP 5? A:28 Please read the release notes at http://www.php.net.

Q:29 How can we convert asp pages to PHP pages? A:29 there are lots of tools available for asp to PHP conversion. you can search Google for that. the best one is available athttp://asp2php.naken.cc./

Q:30 What is the functionality of the function htmlentities? A:30 Convert all applicable characters to HTML entities This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.

Q:31 How can we get second of the current time using date function? A:31 $second = date(s);

Q:32 How can we convert the time zones using PHP? A:32

By using date_default_timezone_get and date_default_timezone_set function on PHP 5.1.0 <?php // Discover what 8am in Tokyo relates to on the East Coast of the US // Set the default timezone to Tokyo time: date_default_timezone_set('Asia/Tokyo'); // Now generate the timestamp for that particular timezone, on Jan 1st, 2000 $stamp = mktime(8, 0, 0, 1, 1, 2000); // Now set the timezone back to US/Eastern date_default_timezone_set('US/Eastern'); // Output the date in a standard format (RFC1123), this will print: // Fri, 31 Dec 1999 18:00:00 EST echo '<p>', date(DATE_RFC1123, $stamp) ,'</p>';?>

Q:33 What is meant by urlencode and urldocode? A:33 URLencode returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+)

signs. It is encoded the same way that the posted data from a WWW form is encoded, that is the same way as in application/x-www-form-urlencoded media type. urldecode decodes any %## encoding in the given string.

Q:34 What is the difference between the functions unlink and unset? A:34 unlink() deletes the given file from the file system. unset() makes a variable undefined.

Q:35 How can we register the variables into a session? A:35 $_SESSION[name] = Mizan;

Q:36 How can we get the properties (size, type, width, height) of an image using PHP image functions? A:36 To To To To know know know know the the the the Image type use exif_imagetype () function Image size use getimagesize () function image width use imagesx () function image height use imagesy() function t

Q:37 How can we get the browser properties using PHP? A:37 By using

$_SERVER['HTTP_USER_AGENT'] variable.

Q:38 What is the maximum size of a file that can be uploaded using PHP and how can we change this? A:38 By default the maximum size is 2MB. and we can change the following setup at php.iniupload_max_filesize = 2M

Q:39 How can we increase the execution time of a PHP script? A:39

by changing the following setup at php.inimax_execution_time = 30

; Maximum execution time of each script, in seconds

Q:40 How can we take a backup of a MySQL table and how can we restore it. ? A:40 To backup: BACKUP TABLE tbl_name[,tbl_name] TO /path/to/backup/directory RESTORE TABLE tbl_name[,tbl_name] FROM /path/to/backup/directorymysqldump: Dumping Table Structure and DataUtility 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 Dont write table creation information (the CREATE TABLE statement). -d, no-data Dont 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!

Q:41 How can we optimize or increase the speed of a MySQL select query? A:41

first of all instead of using select * from table1, use select column1, column2, column3.. from table1 Look for the opportunity to introduce index in the table you are querying. use limit keyword if you are looking for any specific number of rows from the result set.

Q:42 How many ways can we get the value of current session id? A:42 session_id() returns the session id for the current session.

Q:43 How can we destroy the session, how can we unset the variable of a session? A:43 session_unregister Unregister a global variable from the current session session_unset Free all session variables

Q:44 How can we destroy the cookie?

A:44 Set the cookie in past.

Q:45 How many ways we can pass the variable through the navigation between the pages? A:45

GET/QueryString POST

Q:46 What is the difference between ereg_replace() and eregi_replace()? A:46 eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters.eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters.

Q:47 What are the different functions in sorting an array? A:47 Sort(), arsort(), asort(), ksort(), natsort(), natcasesort(), rsort(), usort(), array_multisort(), and uksort().

Q:48 How can we know the count/number of elements of an array? A:48 2 ways a) sizeof($urarray) This function is an alias of count() b) count($urarray)

Q:49 What is the PHP predefined variable that tells the What types of images that PHP supports? A:49 Though i am not sure if this is wrong or not, With the exif extension you are able to work with image meta data.

Q:50 How can I know that a variable is a number or not using a JavaScript?

A:50 bool is_numeric ( mixed var) Returns TRUE if var is a number or a numeric string, FALSE otherwise.or use isNaN(mixed var)The isNaN() function is used to check if a value is not a number.

Q:51 List out some tools through which we can draw E-R diagrams for mysql. A:51 Case Studio Smart Draw

Q:52 How can I retrieve values from one database server and store them in other database server using PHP? A:52 we can always fetch from one database and rewrite to another. here is a nice solution of it.$db1 = mysql_connect(host,user,pwd) mysql_select_db(db1, $db1); $res1 = mysql_query(query,$db1);$db2 = mysql_connect(host,user,pwd) mysql_select_db(db2, $db2); $res2 = mysql_query(query,$db2);At this point you can only fetch records from you previous ResultSet, i.e $res1 But you cannot execute new query in $db1, even if you supply the link as because the link was overwritten by the new db.so at this point the following script will fail $res3 = mysql_query(query,$db1); //this will failSo how to solve that? take a look below. $db1 = mysql_connect(host,user,pwd) mysql_select_db(db1, $db1); $res1 = mysql_query(query,$db1); $db2 = mysql_connect(host,user,pwd, true) mysql_select_db(db2, $db2); $res2 = mysql_query(query,$db2); So mysql_connect has another optional boolean parameter which indicates whether a link will be created or not. as we connect to the $db2 with this optional parameter set to true, so both link will remain live. now the following query will execute successfully. $res3 = mysql_query(query,$db1); Thanks goes to Hasan and Hasin for this solution.

Q:53 List out the predefined classes in PHP? A:53 Directory stdClass __PHP_Incomplete_Class exception

php_user_filter

Q:54 How can I make a script that can be bi-language (supports English, German)? A:54 You can maintain two separate language file for each of the language. all the labels are putted in both language files as variables and assign those variables in the PHP source. on runtime choose the required language option.

Q:55 What are the difference between abstract class and interface? A:55 Abstract class: abstract classes are the class where one or more methods are abstract but not necessarily all method has to be abstract. Abstract methods are the methods, which are declare in its class but not define. The definition of those methods must be in its extending class.Interface: Interfaces are one type of class where all the methods are abstract. That means all the methods only declared but not defined. All the methods must be define by its implemented class.

Q:56 How can we send mail using JavaScript? A:56 JavaScript does not have any networking capabilities as it is designed to work on client site. As a result we can not send mails using JavaScript. But we can call the client side mail protocol mailto via JavaScript to prompt for an email to send. this requires the client to approve it.

Q:57 How can we repair a MySQL table? A:57 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

Q:58 What are the advantages of stored procedures, triggers, indexes? A:58 A stored procedure is a set of SQL commands that can be compiled and stored in the server. Once this has been done, clients dont need to keep re-issuing the entire query but can refer to the stored procedure. This provides better overall performance because the query has to be parsed only once, and less information needs to be sent between the

server and the client. You can also raise the conceptual level by having libraries of functions in the server. However, stored procedures of course do increase the load on the database server system, as more of the work is done on the server side and less on the client (application) side.Triggers will also be implemented. A trigger is effectively a type of stored procedure, one that is invoked when a particular event occurs. For example, you can install a stored procedure that is triggered each time a record is deleted from a transaction table and that stored procedure automatically deletes the corresponding customer from a customer table when all his transactions are deleted.Indexes are used to find rows with specific column values quickly. Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more this costs. If the table has an index for the columns in question, MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. If a table has 1,000 rows, this is at least 100 times faster than reading sequentially. If you need to access most of the rows, it is faster to read sequentially, because this minimizes disk seeks.

Q:59 What is the maximum length of a table name, database name, and fieldname in MySQL? A:59 The following table describes the maximum length for each type of identifier.

Identifier

Maximum Length (bytes)

Database 64 Table Column Index Alias 64 64 64 255

There are some restrictions on the characters that may appear in identifiers:

Q:60 How many values can the SET function of MySQL take? A:60 MySQL set can take zero or more values but at the maximum it can take 64 values

Q:61 What are the other commands to know the structure of table using MySQL commands except explain command? A:61 describe Table-Name;

Q:62 How many tables will create when we create table, what are they? A:62 The .frm file stores the table definition. The data file has a .MYD (MYData) extension. The index file has a .MYI (MYIndex) extension,

Q:63 What is the purpose of the following files having extensions 1) .frm 2) .myd 3) .myi? What do these files contain? A:63 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,

Q:64 What is maximum size of a database in MySQL? A:64 If the operating system or filesystem places a limit on the number of files in a directory, MySQL is bound by that constraint.The efficiency of the operating system in handling large numbers of files in a directory can place a practical limit on the number of tables in a database. If the time required to open a file in the directory increases significantly as the number of files increases, database performance can be adversely affected. The amount of available disk space limits the number of tables. MySQL 3.22 had a 4GB (4 gigabyte) limit on table size. With the MyISAM storage engine in MySQL 3.23, the maximum table size was increased to 65536 terabytes (2567 1 bytes). With this larger allowed table size, the maximum effective table size for MySQL databases is usually determined by operating system constraints on file sizes, not by MySQL internal limits.The InnoDB storage engine maintains InnoDB tables within a tablespace that can be created from several files. This allows a table to exceed the maximum individual file size. The tablespace can include raw disk partitions, which allows extremely large tables. The maximum tablespace size is 64TB. The following table lists some examples of operating system file-size limits. This is only a rough guide and is not intended to be definitive. For the most up-to-date information, be sure to check the documentation specific to your operating system.

Operating System File-size LimitLinux 2.2-Intel 32-bit 2GB (LFS: 4GB) Linux 2.4+ (using ext3 filesystem) 4TB Solaris 9/10 16TB NetWare w/NSS filesystem 8TB Win32 w/ FAT/FAT32 2GB/4GB Win32 w/ NTFS 2TB (possibly larger) MacOS X w/ HFS+ 2TB

Q:65 Give the syntax of Grant and Revoke commands? A:65 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 privileges b) combination of create, drop, select, insert, update and delete etc.We can grant rights on all databse by using *.* 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 userThe generic syntax for revoke is as following > REVOKE [rights] on [database/s] FROM [username@hostname] now rights can be as explained above a) All privileges 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

Q:66 Explain Normalization concept? A:66 The normalization process involves getting our data to conform to three progressive normal forms, and a higher level of normalization cannot be achieved until the previous levels have been achieved (there are actually five normal forms, but the last two are mainly academic and will not be discussed).First Normal FormThe First Normal Form (or 1NF) involves removal of redundant data from horizontal rows. We want to ensure that there is no duplication of data in a given row, and that every column stores the least amount of information possible (making the field atomic).Second Normal FormWhere the First Normal Form deals with redundancy of data across a horizontal row, Second Normal Form (or 2NF) deals with redundancy of data in vertical columns. As stated earlier, the normal forms are progressive, so to achieve Second Normal Form, your tables must already be in First Normal Form.Third Normal Form I have a confession to make; I do not often use Third Normal Form. In Third Normal Form we are looking for data in our tables that is not

fully dependant on the primary key, but dependant on another value in the table

Q:67 How can we find the number of rows in a table using MySQL? A:67 Use this for mysql >SELECT COUNT(*) FROM table_name;

Q:68 How can we find the number of rows in a result set using PHP? A:68

$result = mysql_query($sql, $db_link); $num_rows = mysql_num_rows($result); echo "$num_rows rows found";

Q:69 How many ways we can we find the current date using MySQL? A:69 SELECT CURDATE(); CURRENT_DATE() = CURDATE() for time use SELECT CURTIME(); CURRENT_TIME() = CURTIME()

Q:70 What are the advantages and disadvantages of Cascading Style Sheets? A:70 External Style SheetsAdvantagesCan control styles for multiple documents at once. Classes can be created for use on multiple HTML element types in many documents. Selector and grouping methods can be used to apply styles under complex contextsDisadvantagesAn extra download is required to import style information for each document The rendering of the document may be delayed until the external style sheet is loaded Becomes slightly unwieldy for small quantities of style definitionsEmbedded Style Sheets Advantages Classes can be created for use on multiple tag types in the document. Selector and grouping methods can be used to apply styles under complex contexts. No additional downloads necessary to receive style information Disadvantages This method can not control styles for multiple documents at once Inline Styles

Advantages Useful for small quantities of style definitions. Can override other style specification methods at the local level so only exceptions need to be listed in conjunction with other style methods Disadvantages Does not distance style information from content (a main goal of SGML/HTML). Can not control styles for multiple documents at once. Author can not create or control classes of elements to control multiple element types within the document. Selector grouping methods can not be used to create complex element addressing scenarios

Q:71 What type of inheritance that PHP supports? A:71 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.

Q:72 What is the difference between Primary Key and Unique key? A:72 Primary Key: A column in a table whose values uniquely identify the rows in the table. A primary key value cannot be NULL. Unique Key: Unique Keys are used to uniquely identify each row in the table. There can be one and only one row for each unique key value. So NULL can be a unique key.There can be only one primary key for a table but there can be more than one unique for a table.

The structure of table view buyers is as follows: Q:73

Field user_pri_id userid

Type int(15) varchar(10)

Null Key PRI YES

Default null null

Extra auto_increment

the value of user_pri_id the last row 999 then What will happen in the following conditions? Condition1: Delete all the rows and insert another row then. What is the starting value for this auto incremented field user_pri_id , Condition2: Delete the last row(having the field value 999) and insert another row then. What is the value for this auto incremented field user_pri_id

A:73 In both cases let the value for auto increment field be n then next row will have value n+1 i.e. 1000

Q:74 What are the advantages/disadvantages of MySQL and PHP? A:74 Both of them are open source software (so free of cost), support cross platform. php is faster then ASP and JSP.

Q:75 What is the difference between GROUP BY and ORDER BY in Sql? A:75 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

Q:76 What is the difference between char and varchar data types? A:76 Set char to occupy n bytes and it will take n bytes even if u r storing a value of n-m bytes Set varchar to occupy n bytes and it will take only the required space and will not use the n bytes eg. name char(15) will waste 10 bytes if we store mizan, if each char takes a byte eg. name varchar(15) will just use 5 bytes if we store mizan, if each char takes a byte. rest 10 bytes will be free.

Q:77 What is the functionality of md5 function in PHP? A:77 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.

Q:78 How can I load data from a text file into a table? A:78 you can use LOAD DATA INFILE file_name; syntax to load data from a text file. but you have to make sure thata) data is delimited b) columns and data matched correctly

Q:79 How can we know the number of days between two given dates using MySQL? A:79 SELECT DATEDIFF(2007-03-07,2005-01-01);

Q:80 How can we know the number of days between two given dates using PHP? A:80 $date1 = date(Y-m-d); $date2 = 2006-08-15; $days = (strtotime($date1) strtotime($date2)) / (60 * 60 * 24);

Write the statements that are used to connect PHP with MySQL

The statements that can be used to connect PHP wil MySQL is: <? $conn = mysql_connect('localhost'); echo $conn; ?> This statement gets the resource of the localhost. There are other different ways with which you can connect to the database and they are as follows: <? mysql_connect('db.domain.com:33306','root','user'); mysql_connect('localhost:/tmp/mysql.sock'); mysql_connect('localhost','rasmus','foobar', true,MYSQL_CLIENT_SSL|MYSQL_CLIENT_COMPRESS); ?>
How to use HTTP Headers inside PHP? Write the statement through which it can be added?

HTTP headers can be used in PHP by redirection which is written as: <?header('Location: http://www.php.net')?> The headers can be added to HTTP response in PHP using the header(). The response headers are sent before any actual response being sent. The HTTP headers have to be sent before taking the output of any data. The statement above gets included at the top of the script.

Why PHP is also called as Scripting language?

PHP is basically a general purpose language, which is used to write scripts. Scripts are normal computer files that consist of instructions written in PHP language. It tells the computer to execute the file and print the output on the screen. PHP is used for webpages and to create websites, thus included as scripting language.
Why many companies are switching their current business language to PHP? Where PHP basically used?

PHP is rapidly gaining the popularity and many companies are switching their current language for this language. PHP is a server side scripting language. PHP executes the instructions on the server itself. Server is a computer where the web site is located. PHP is used to create dynamic pages and provides faster execution of the instructions.
What is the use of PEAR in php?

PEAR is known as PHP Extension and Application Repository. It provides structured library to the PHP users and also gives provision for package maintenance.
What is the difference between PHP and JavaScript?

The difference lies with the execution of the languages. PHP is server side scripting language, which means that it cant interact directly with the user. Whereas, JavaScript is client side scripting language, that is used to interact directly with the user..
What is the difference between $message and $$message?

The main difference between $message and $$message is that former one is a simple variable and later is a reference variable. $message is a variable with a fixed name and it consists of a fixed value. $$messages contains the variable itself.
What does ODBC do in context with PHP?

PHP supports many databases like dBase, Microsft SQL Server, Oracle, etc. But, it also supports databases like filePro, FrontBase and InterBase with ODBC connectivity. ODBC stands for Open Database connectivity, which is a standard that allows user to communicate with other databases like Access and IBM DB2.

Why PHP is sometimes called as embedded scripting language?

PHP is a high level language which is used to allow users to write and understand it in human readable form and also use an interpreter to interpret the code which user write for the computer. PHP is used as an embedded scripting language for the web. PHP is embedded in HTML code. HTML tags are used to enclose the PHP language. HTML is used and PHP is code written in it in the same way as you write JavaScript in HTML.
What is difference between require_once(), require(), include()?

require() includes and evaluates a specific file, if the file is not found then it shows a Fatal Error. require_once() includes only the file which is not being included before. It is used to be recommended for the files where you have lots of functions stored. include() includes the file, even if the file is not found, but it gives a warning to the user to include().
How the web server interprets PHP and interacts with the client?

After installing and configuring the PHP, the web When PHP is installed, the Web server looks for PHP code that is embedded in HTML file with its extension. The extensions which are used are .php or .phtml. When web server receives a request for the file with an appropriate extension, HTML statements are processed and PHP statements are executed on the server itself. When the processing gets over the output is being shown in HTML statements.
PHP being an open source is there any support available to it?

PHP is an open source language, and it is been said that it has very less support online and offline. But, PHP is all together a different language that is being developed by group of programmers, who writes the code. There is lots of available support for PHP, which mostly comes from developers and PHP users.

Вам также может понравиться