0% found this document useful (0 votes)
5 views

PHP Question Answerggupv

Gvyvubbj

Uploaded by

shamim20517
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

PHP Question Answerggupv

Gvyvubbj

Uploaded by

shamim20517
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1. What is PHP?

PHP stands for Hypertext Preprocessor. It is an open-source, general-purpose,


scripting language that is especially used for web development.

2. What are the variable-naming rules you should follow


in PHP?

There are two main rules that you have to follow when naming a variable in PHP.
They are as follows:

• Variables can only begin with letters or underscores.


• Special characters such as +, %, -, &, etc. cannot be used.

Naming a variable in PHP is simple, but some rules must be followed. Variable names
must begin with a letter or an underscore, followed by any number of letters, numbers,
or underscores. Additionally, PHP variable names are case sensitive, meaning that a
variable named 'myVariable' is distinct from 'my variable.' Furthermore, variable names
cannot use PHP keywords such as 'int,' 'float,' or 'array.'

3. Differentiate between variables and constants in PHP.


Variable Constant
Variables can have changed paths Constants cannot be changed
The default scope is the current access scope Constants can be accessed throughout without
any scoping rules
The $ assignment is used for definition Constants are defined using the define()
function
Compulsory usage of the $ sign at the start No need for the $ sign for constants
4. What is the use of $message and $$message in PHP?

• Both $message and $$message are variables in PHP and the difference lies
in the name. While $message is a variable with a fixed name, $$message is a
variable with a name that is actually stored in $message.
• Consider the following example:
1If $message consists of ‘var’, then $$message is nothing but ‘$var’.

5. What is the difference between "echo" and "print" in


PHP?

The primary difference between "echo" and "print" in PHP is that "echo" is a language
construct, and "print" is a function. "echo" also has slightly better performance and is
more succinct, making it preferable in situations where performance and size matter.

6. How can PHP interact with HTML?

Yes, HTML and PHP interaction is at the core of what makes PHP’s functionality.
PHP scripts have the ability to generate HTML mode and move around information
very easily.

PHP is a server-side scripting language, while HTML is a client-side language. This


interaction helps bridge the gaps and use the best of both languages.

PHP is designed to interact with HTML. It’s possible to embed PHP scripts in an HTML
page without a problem and transfer information from HTML to PHP.

7. Is PHP a case-sensitive scripting language?


The answer to this is both yes and no. Variables and their declaration in PHP are
completely case sensitive while function names are not.

For example, user-defined functions in PHP can be defined in uppercase but later
referred to in lowercase, and it would still function normally.

8. What are the types of variables present in PHP?

There are eight primary data types in PHP as shown below:

• Array: A named and ordered collection of data


• Boolean: A logical value (True or False)
• Double: Floating point numbers such as 5.1525
• Integer: Whole numbers without a floating point
• Object: An instance of classes, containing data and functions
• NULL: A special data type, supporting only the NULL data
• Resource: Special variables that hold references to external resources
• String: A sequence of characters such as, “Hello learners!”

9. What are the popular frameworks in PHP?


Some popular PHP frameworks are:

• CodeIgniter

• CakePHP

• Symfony

• Zend Framework

• Yii 2
10. What are some of the key features of PHP?

Some of the key features of PHP are:

• It is completely open-source.
• It is compatible with many databases, like MySQL, SQLite, etc.
• It is platform-independent, that is, it can be run on any operating system
like Linux, Unix, Windows, etc.
• It is object-oriented, that is it supports object oriented functionalities
like encapsulation, inheritance, abstraction, and polymorphism.

12. What is the difference between == and === operators


in PHP?

“==” operator is used to check two values without checking datatypes.

“===” operator is used to do a strict check that also checks for datatypes along with
values

13. List the main types of errors in PHP and explain their
differences.

There are three main error types in PHP:

• Notices. These are non-critical errors that can occur during the script
execution. These are not visible to users. Accessing an undefined variable is
an example of a 'Notice'.

• Warnings. These are more critical than Notices, but just like them, Warnings
don't interrupt the script execution. However, these are visible to the user by
default. Example: include() a file that doesn't exist.
• Fatal. This is the most critical error type which, when occurs, immediately
terminates the script execution. Accessing a property of a non-existent object
or require() a non-existent file is an example of this error type

14. What is the difference between ASP.NET and PHP?

ASP.NET PHP
A programming framework A scripting language
Compiled and executed Interpreted mode of execution
Designed for use on Windows Platform independent

15. Differentiate between GET and POST methods in PHP.

GET Method POST Method


The GET method can only send a maximum of There is no restriction on the data size
1024 characters simultaneously
GET does not support sending binary data POST supports binary data as well as ASCII
QUERY_STRING env variable is used to access The HTTP protocol and the header are used to
the data that is sent push the data
The $_GET associative array is used to access The $_POST associative array is used to
the sent information access the sent information here

You might also like