Jun 6, 2008

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.





No comments: