Home

PHP

PHP stands for hypertext preprocessor.It is widely used for web developement.

Find few questions and their answers which will be helpfull for development as well as interview preparation.

1) What is the full form of PHP ?

Ans: Hypertext Preprocessor

2) Differene between require and include ?

Ans: If a file is not found using require then it will throw a fatal error and execution will be halt. In case of include if the file is not found then system will throw a warning but execution will continue .

3) How do you denote a variable in PHP ?

Ans: $a=123;

where $a is the variable($ is used for variable denotion).

4) What is the use of substr ?

Ans: Suppose $str= “abcdef”; Now you want to print only abcde, what will you do ?

Just do this, substr($str, 0, -1);  // returns “abcde”

Look at below example for better understanding:

$str= substr(“abcdef”, 2, -1);  // returns “cde”
$str= substr(“abcdef”, 4, -4);  // returns “”
$str= substr(“abcdef”, -3, -1); // returns “de”

5) What is the use of trim function in PHP ?

Ans: Strip whitespace (or other characters) from the beginning and end of a string .

like suppose trim($string) where $string = ” abc”;

You can see above that $string has a value abc where there is a space before abc.So if you use trim($string),it will return only abc and will strip the whitespace.

6) What is the difference between print and echo ?

Ans: Both of them are language constructs which are used to display string .

We can use echo  for multiple parameters and echo is slightly faster than print.

7) How to  connect to MySql database using PHP ?

Ans: $connection = mysqli_connect(“database-hostname”,”database-username”,”database-password”,”database name”);

//Error checking

if (!$connection) {
die(‘Connection Error: ‘ . mysqli_connect_error());
}

The default username of mysql used to be root on localhost.The default password of mysql used to blank on localhost.

8 thoughts on “Home”

  1. Hey there! Quick question that’s completely off topic.
    Do you know how to make your site mobile friendly?
    My weblog looks weird when browsing from my iphone 4.
    I’m trying to find a template or plugin that might be able to
    fix this problem. If you have any suggestions, please share.

    Thank you!

    1. Sorry for late response . I can make your website mobile friendly in reasonable rates .
      If your website is done using wordpress then you will find most of the templates are mobile friendly .
      Please let me know if you want me to work on your mobile issues .

  2. Hi there, You have done a fantastic job.
    I will definitely digg it and personally recommend to my friends.
    I’m sure they’ll be benefited from this site.

Leave a Reply

Your email address will not be published.