Monday, January 27, 2020

php interview questions

Q #1) What is PHP?
Answer:
PHP is one of the popular server-side scripting languages for developing a web application.
The full form of PHP is Hypertext Preprocessor. It is used by embedding HTML for creating dynamic content, communicating with a database server, handling session etc.
Q #2) Why do we use PHP?
Answer:
There are several benefits of using PHP. First of all, it is totally free to use. So anyone can use PHP without any cost and host the site at a minimal cost.
It supports multiple databases. The most commonly used database is MySQL which is also free to use. Many PHP frameworks are used now for web development, such as CodeIgniter, CakePHP, Laravel etc.
These frameworks make the web development task much easier than before.
Q #3) Is PHP a strongly typed language?
Answer:
No. PHP is a weakly typed or loosely typed language.
Which means PHP does not require to declare data types of the variable when you declare any variable like the other standard programming languages C# or Java. When you store any string value in a variable then the data type is the string and if you store a numeric value in that same variable then the data type is an Integer.
Sample code:
1$var "Hello"//String
2$var = 10; //Integer
Q #4) What is meant by variable variables in PHP?
Answer:
When the value of a variable is used as the name of the other variables then it is called variable variables. $$ is used to declare variable variables in PHP.
Sample code:
1$str "PHP";
2$$str " Programming"//declaring variable variables
3echo "$str ${$str}"//It will print "PHP programming"
4echo "$PHP"//It will print "Programming"
Q #5) What are the differences between echo and print?
Answer:
Both echo and print method print the output in the browser but there is a difference between these two methods.
echo does not return any value after printing the output and it works faster than the print method. print method is slower than the echo because it returns boolean value after printing the output.
Sample code:
1echo "PHP Developer";
2$n print "Java Developer";

No comments:

Post a Comment

Which Python course is best for beginners?

Level Up Your Python Prowess: Newbie Ninjas: Don't fret, little grasshoppers! Courses like "Learn Python 3" on Codecade...