Q1. What is PHP?
Ans. PHP is a server-side scripting language. The full form of PHP is Hypertext Preprocessor. PHP is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
Q2. What is a variable?
Ans. The variable in a program is used to store some values/data which can be used later in a program.
Q3. How to declare variables in PHP?
Ans. To declare variable in PHP Dollar($) symbol is use. E.g <?php $varible = ‘PHP’; ?>
Q4. What is constant?
Ans. The constant is an identifier (name) for a simple value. The constant value cannot change during the execution of the program. Constants are case-sensitive.
Q5. What is the differentiate between variables and constants in PHP?
S. No. | Variables | Constants |
---|---|---|
01 | A variable can be changed during the execution of the program. | The constant value can’t be changed during the execution of the program. |
02 | Variables are declared with the dollar sign ($). | Constants are not declared with the dollar sign ($). |
03 | The variables are defined by simple assignment. | The constants can’t be defined by simple assignments. They are defined using the inbuild define() function. |
04 | The default scope of the variable is the current access scope. | The constants can be accessed anywhere without any scoping rules. |
Q6. Is PHP a case-sensitive language?
Ans. PHP is considered a partial case-sensitive language. The variable names in PHP are completely case-sensitive whereas function names 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 call them in uppercase would still function normally.
Q7. How to Comments in PHP?
Ans. There are 3 ways to comments in PHP :-
(a) <?php // This is a single-line comment ?>
(b) <?php # This is also a single-line comment ?>
(c) <?php /* This is a multiple
line comment */ ?>
Q8. What is the echo in PHP?
Ans. The echo is a statement in PHP, this is used to display the output on the screen. echo can be used with or without parentheses: echo(), and echo. It does not return any value.
Q9. What is Print in PHP?
Ans. The print is also a statement in PHP, It is used as an alternative to echo many times to display the output on the screen. print can be used with or without parentheses. print always returns an integer value, i.e 1.
Q10. What is the basic PHP Syntax?
Ans. The PHP code can be placed anywhere in the document. But the condition is that A PHP code must be written between <?php
?>
tags