Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Tell me some of the disadvantages of PHP

Answer»

The cons of PHP are:

  • PHP is not suitable for giant content-based web applications.
  • Since it is open-source, it is not SECURE. Because ASCII text files are EASILY available.
  • Change or modification in the core behavior of online applications is not allowed by PHP.
  • If we use more features of the PHP framework and tools, it will cause poor performance of online applications.
  • PHP features a poor quality of handling errors. PHP lacks debugging tools, which are needed to look for WARNINGS and errors. It has only a few debugging tools in COMPARISON to other programming languages.
2.

What is the difference between “echo” and “print” in PHP?

Answer»

The main difference between echo and print in PHP are given below:

echoprint
echo can output one or more strings.print can only output one string and it always RETURNS 1.
echo is faster than print because it does not RETURN any value.print is SLOWER compared to echo.
If you WANT to pass more than one parameter to echo, a parenthesis should be used.Use of parenthesis is not required with the argument list.
3.

What are the rules for naming a PHP variable?

Answer»

The following two rules are needed to be followed while naming a PHP variable:

  • A variable must start with a DOLLAR symbol, followed by the variable name. For example: $PRICE=100; where price is a variable name.
  • Variable names must begin with a letter or underscore.
  • A variable name can CONSIST of letters, numbers, or UNDERSCORES. But you cannot use CHARACTERS like + , – , % , & etc.
  • A PHP variable name cannot contain spaces.
  • PHP variables are case-sensitive. So $NAME and $name both are treated as different variables.
4.

What are the different types of variables present in PHP?

Answer»

Types of PHP Variables

There are 8 primary DATA types in PHP which are used to construct the variables. They are:

  • Integers: Integers are whole numbers without a floating-point. Ex: 1253.
  • Doubles: Doubles are floating-point numbers. Ex: 7.876
  • Booleans: It represents two logical states- true or false.
  • NULL: NULL is a special type that only has one value, NULL. When no value is assigned to a variable, it can be assigned with NULL.
  • Arrays: Array is a named and ordered COLLECTION of similar type of data. Ex: $colors = array("red", "yellow", "BLUE");
  • Strings: Strings are a sequence of characters. Ex: “Hello InterviewBit!”
  • Resources: Resources are special variables that consist of references to resources external to PHP(such as database connections).
  • Objects: An instance of classes containing data and functions. Ex: $mango = new FRUIT();
5.

Is PHP a case-sensitive language?

Answer»

PHP can be considered as a partial case-sensitive language. The variable names are completely case-sensitive but function names are not. ALSO, user-DEFINED functions are not case-sensitive but the rest of the language is case-sensitive.

For example, user-defined functions in PHP can be defined in lowercase but LATER referred to in uppercase, and it WOULD STILL function normally.

6.

Explain the difference between $message and $$message.

Answer»

The main difference between the $MESSAGE and $$message is given below:

$message$$message
$message is a regular variable.$$message is a reference variable.
It has a FIXED name and stores a fixed value.It stores DATA about the variable.
Data stored in $message is fixed.The value of the $$message can CHANGE DYNAMICALLY as the value of the variable changes.
7.

What does PEAR stands for?

Answer»

PEAR stands for “PHP Extension and Application Repository”. PEAR is a FRAMEWORK and repository for all of the reusable PHP components.

PEAR provides a higher level of programming for web developers. It contains all KINDS of PHP code snippets and libraries. It also provides you with a command-line interface to automatically INSTALL packages.

8.

Differentiate between variables and constants in PHP

Answer»

Few difference between variables and constants in PHP are given below:

VariablesConstants
The value of a variable can be CHANGED during the execution.The constant value can’t be changed during script execution.
Variables require COMPULSORY usage of the $ sign at the start.No dollar sign ($) is REQUIRED before using a constant.
It is possible to define a variable by simple assignment.Constants can’t be defined by simple assignments. They are defined using the define() function.
The default scope is the current ACCESS scope.Constants can be accessed throughout without any scoping rules.