Archive for June, 2006

Questions on Bitwise Operators in PHP

June 26, 2006 2 comments

Q:- What do you mean by bitwise operators?
Ans: The bitwise operators act on the binary representation on their operands. Each operand is first turned into a binary representation of the value before operation.

Q:- Do these operators work only on numbers?
Ans: No, they work for numbers as well as strings but they vary in their treatment of string operands of different lengths.

Q:- What is bitwise negation(~)?
Ans: It changes 1s to 0s and 0s to 1s in the binary representations of the operands. For string operands, the resulting value is a string of same length, with each character in the string negated. Read more…

Categories: PHP

Interview Questions on PHP

June 22, 2006 14 comments

Hey, I am back with some more questions on PHP. Enjoy!!

Q:- What is the difference between “GET” and “POST” methods?

Ans. Get and Post are methods used to send data to the server with the submission of the form. The default method is GET.

* The browser appends the data onto the url when GET method is used, while the data is sent as standard input when POST method is used.
* When the processing of the form has no side effects, means just for getting(retrieving) data, the GET method should be used and POST method should be used when the form processing has side effects(for example, modification of a database or subscription to a service).

Example: Suppose Sachin is filling up a form with the following information:

Name: Sachin Tendulkar



If the form uses GET method then the location box will show the string after submitting the form like this: &Age=35&Sex=Male&Choice=Cricket
and if POST is used, then the location box will show:

Q:- What is the difference between echo and print?

Ans. Both are the constructs to print the string on the screen. echo just outputs the contents to the screen following the construct while print returns TRUE on successful output and FALSE if it was unable to print out the string. echo can take multiple parameters while print cannot. Also echo is faster than print in execution.

Q:- What is the difference include() and require()?
Ans. Both the functions are used to include and evaluate the specific file, but the only difference is require() produces FATAL ERROR and stops the execution if the specified file is not found while include() produces a warning message only and proceeds the execution.

Q:- What is meant by nl2br()?

Ans. This function inserts HTML line breaks before all newlines in a string

example: <?php
echo nl2br(“I am not getting\n what you are saying”);
Output: I am not getting<br />
what you are saying

Q:- What is the differen between strstr() and stristr() functions?

Ans. strstr() function is used to return the sub string from first occurrence of string point from the string base.If string point is not found, returns FALSE. syntax: strstr(string base,string point)
examle: <?php
$email = ‘’;
$domain = strstr($email, ‘@’);
echo $domain;
stristr() does the same thing in Case-insensitive manner.

Who will come with smart comments? Let’s see.

Categories: PHP

Who would like to be the first!!

June 14, 2006 1 comment

Just wondering!! While writing for the new post, suddenly clicked that after every post, the bottom line says “Smart suggestions are always welcome”, how the blog sites provide this facility. Means how anyone can add comments, can’t edit the posts, rate the post etc. I want to know at coding level. I am digging for the solution. Who would like to be the first to provide me the “digging tool”? That can be anything, site references, code pieces, blog references.

Soon you will get my new post regarding this. Lets make a race.

Categories: PHP

Basic Questions on PHP

June 10, 2006 14 comments

Hey all! glad to see the comment posted on my previous blog i.e. Templates With PHP by Mayank. As he demanded to say about some basics about PHP, here I am going to post some basic questions on PHP which will facilitate the beginners and also those preparing for interviews. Enjoy!!

Q:- What is the full form of PHP?

A:- The full form of PHP is “Hypertext Preprocessor” the naming style of GNU.

Q:- Which type of language PHP is?

A:- PHP is server side scripting language often written in an HTML context. A PHP script is not directly sent to the client by the server. It is parsed by the PHP engine. The output from PHP code is combined with HTML in the script and the result sent to the user.

Q:- What is the difference between PHP and PERL programming languages?

A:- Perl programmer must use an external library or write code to acquire the data submitted by the user of web page, whereas PHP makes this data automatically available. A Perl programmer must install modules to enable him to write database-driven environments, whereas PHP bundles a powerful SQL database library and provides built-in support for a whole range of third-party databases.

Q:- What is the Zend Engine?

A:- Zend is an open source scripting engine that sits below the PHP-specific modules. The first version of the Zend Engine was introduced in 1999 along-with PHP version 4. The performance, reliability and extensibility of the engine played a significant role in increasing the popularity of PHP.

Q:- Which platforms, servers, and databases are supported by PHP?

A:- PHP is truly cross-platform. It runs on WINDOWS, most versions of UNIX, LINUX, and Macintosh OS. It supports a range of Web servers including APACHE, Microsoft’s Internet Information Server, WebSite Pro, the iPlanet Web Server, and Microsoft’s Personal Web Server.

Q:- What is the mode of installed PHP on server?

A:- On most servers PHP can be installed as a server module. Means it runs as part of the server process rather than the separate application. PHP is also installed as a standalone command-line application.

May I feel now the beginners are feeling free!! Please let me know your level of comfort. I will continue to post whatever I know.

Categories: PHP

Templates with PHP

June 3, 2006 4 comments

image167.jpgPHP programmers several times find themselves in very irritating situation when the code gets mixed up with HTML code. It is very complex to handle the mixed up code, specially at the time of customization of web applications. The smart way of getting out of these situations is the use of Templates. By the use of the templates the programmers can separate their PHP code to HTML code. It also makes easier to put conditional checking on the HTML code.

Whatever templates do, PHP can also does the same in far better way. So why we should use templates?

Well, my points to use templates are:

  • to make the code easily readable,
  • to separate the business logic from the UI of the web applications,
  • it seperates code from contents,
  • it makes easy to customize the web application at UI level,
  • also easy to customize the web application by non-PHP programmer.
  • you can cache your templates to improve the performance.

These are my point in favour of templates. All are invited with their smart suggestions.

Categories: PHP