Jun 6, 2008

I said more on PHP didn't I .....

Q. What is a query string?
A. A query string is attached to the end of the URL in a link. A query string can consists of as many name/value pairs as developer wants to supply.

Q. What is HTML form element?
A. The user fills out the various text boxes and clicks a submit button when ready, the information that is supplied is then bundled up in one of the two ways and sent to the web server. The web server can then pull out this information and supply it to the PHP engine. PHP manipulates the information and sends it back as a part of HTTP response to the browser. Values submitted in form are always string.

Q. Can we use more than one submit button?
A. Yes, by changing their name.

Q. How can we submit form without the submit button?
A. We can use simple java script code linked to an event trigger of any form field. documetn.form.submit()

Q. In how many ways can we retrieve the data from result set of mysql?
A. As individual objects or as set of arrays.

Q. How many types of tags are available in PHP?
A. Four
standard tags, short tags, script tags, ASP tags.

Q. How does PHP limits the use of whitespaces?
A. We cannot have any whitespaces between We cannot break apart keywords.
We cannot break apart variable names and function names.

Q. How many types of data types are there?
A. Scalar and composite.

Q. What is NULL ?
A. NULL indicates that the variable has no value. A variable is considered to be NULL if it has been assigned the value NULL, or if it has not yet been assigned a value at all although in latte case PHP may output a warning if we attempt to use the variable.

Q. What is resource data type?
A. The resource data type is used to indicate external resources that not used natively by PHP but that have special meaning in the context of a special operation. We cannot convert any value to resource however a resource can be converted to a numeric or string data type in which case PHP will return the numeric ID of the resource.

Q. What is variables variable or $$?
A. It is a variable whose name is contained in another variable.

Q. How do we determine if variable exists?
A. A call to isset() will return ture if a variable exits and has a value other than NULL.

All about Php and more to come........

  1. Difference between Echo and Print?


Ans. Print return its success as a boolean and echo does not returns anything.


  1. How can I remove spaces from around the string?

Ans. By using TRIM function.


  1. How do I calculate MD5 hash of a string?

Ans. $md5=md5($text); md5 is a secure hashing function. No matter how long data stream it converts into a digest of a fixed size.


  1. How do I convert newlines to HTML line break tags?

Ans. Nl2br is used for this.


  1. How do I fetch metatags from page using PHP?

Ans. $gettags = get_meta_tags(“http://...................”);

foreach ($gettags as $i => $value)

echo .........;

  1. How do I remove trailing whitespace?

Ans. By using CHOP function.


  1. How do I turn a sting into an array?

Ans. $string= “ array”;

$array=explode(“,'',$sring);


  1. What is the difference join and implode in PHP?

Ans. Both are just variants of same thing


  1. What is an Echo function?

Ans. Echo function is actually not a function but a language construct, meaning that it doesnt need parentheses to contain arguments and it doesnt require a return a value.


  1. How do online PHP programs run?

Ans online php programs run when a request is made to the Web server. The request tries

to get to the web server to retrieve and send the file requested. But before the response is composed, the php engine has chance to process the php code in the file. Only a single php file can run at a given time because only one file can be requested at a time from the server.


  1. How can we convert data types in PHP?

Ans The php function gettype() can be used to determine the current type of the variable and settype() forces a variable to be of particular type.


  1. What is the difference between Unary operator and binary operator?

Ans Operator that need only one operand are known as Unary operator like ++ , -- . Operators that need two operands are called binary operators like $a = $b;


13 what is strlen() function?

Ans. The strlen() function finds the length of the string it counts all the characters and returns the total.


  1. what is strstr() function?

Ans. Gets any part of the string thats after the first instance of a particular characters or string within a string returns True or False.


  1. What is chr() function?

Ans. Returns a string character value corresponding to the decimal ASCII value entered as a argument.


  1. What are Arrays?

Ans. Arrays are variables of type array. Technically, arrays are lists made up of keys the index and values. They are almost like mini relational database that is dynamic.


  1. Is array() a functin or a language construct?

Ans. The array() function is a language construct not a function. It is used to create an array and accepts the values as arguments. PHP arrays always keep index numbers.


  1. What is print_r ?

Ans. It enables us to print the entire contents of an array along with the name of each indexed elements.


  1. what is count() function?

Ans. It is used to count the total no. elements in an array.


  1. What is array_count_values ?

Ans. It returns the frequency of occurences of matching values.


  1. What is array_flip() ?

Ans . It is used to swap value for key name and vice-versa.


  1. What is the difference between sort and asort?

Ans. The sort function rebuilds the index into the proper order whereas changing the order of the elements on the other hand asort does not change the index values.


  1. What are superglobal arrays?

Ans. The predefined arrays which can be accessed from anywhere in a PHP prog. Without having to use global keyword and without regard for scope.