PHP Interview Question Set 3

Categories: PHP

Which programming language does PHP resemble to?

PHP has borrowed its syntax from Perl and C.


What is "echo" in PHP?

PHP echo output one or more string. It is a language construct not a function. So the use of parentheses is not required. But if you want to pass more than one parameter to echo, the use of parentheses is required.

Syntax:

void echo ( string $arg1 [, string $... ] )  


What is "print" in PHP?

PHP print output a string. It is a language construct not a function. So the use of parentheses is not required with the argument list. Unlike echo, it always returns 1.

Syntax:

int print ( string $arg)  


What is the difference between "echo" and "print" in PHP?

a) Echo can output one or more string but print can only output one string and always returns 1.

b) Echo is faster than print because it does not return any value.


How a variable is declared in PHP?

A PHP variable is the name of the memory location that holds data. It is temporary storage.

Syntax:

$variableName=value;  



What is the difference between $message and $$message?

  1. $message stores variable data while $$message is used to store variable of variables.
  2. $message stores fixed data whereas the data stored in $$message may be changed dynamically.


What are the ways to define a constant in PHP?

PHP constants are name or identifier that can't be changed during execution of the script. PHP constants are defined in two ways:

Using define() function

Using const() function


 What are magic constants in PHP?

PHP magic constants are predefined constants, which change based on their use. They start with a double underscore (__) and end with a double underscore (__).


How many data types are there in PHP?

PHP data types are used to hold different types of data or values. There are 8 primitive data types which are further categorized in 3 types:

  1. Scalar types
  2. Compound types
  3. Special types

Top Blogs
PHP freshers Interview Questions PHP Interview Questions and Answers for Freshers & Experienced Published at:- PHP Tutorial From beginner Published at:- PHP Interview Question Set 1 Published at:- PHP Interview Question Set 3 Published at:- PHP Interview Question Set 4 Published at:- PHP Interview Question Set 6 Published at:- PHP Interview Question Set 7 Published at:- PHP Interview Question Set 8 Published at:- PHP Interview Question Set 9 Published at:- Top 5 PHP Structures Published at:- 8 Motivations To pick Php web Advancement for IT Business Published at:-
R4R.co.in Team
The content on R4R is created by expert teams.