Introduction to PHP Exercise
Chapter 7
Introduction to PHP
A. Fill in the blanks:
1. The Menu Bar displays the various options that are used for performing different activities.
2. The Tool Bar consists of commands that are frequently used while creating, editing, formatting and debugging the code.
3. The Code Editor window is used to write and edit the code.
4. The Status Bar display the status related to characters, lines, column and a selection of the current file you are working with.
5. An operator needs one or more operands to perform any operation.
B. Write T for true and F for false:
1. In PHP an identifier can consists of any combination of letters, digits, and an underscore.
True
2. In PHP both uppercase and lowercase letters can be used in naming an identifiers.
True
3. The relational operators are used to evaluate two or more conditional statements.
True
4. The POST method is used with the <form> tag.
True
5. An identifier name start with &.
False
C. Answer in one word:
1. What is the ability of a code to run any kind of operating system called?
Portable
2. Name the components that display the name of the current code window.
Title Bar
3. Name the window that is used to write the code.
Code Editor
4. What are the websites that share the user data with each other called?
Dynamic Website
D. Select the correct option:
1. The ____________ operators are used to perform the basic mathematical calculations.
a. Arithmetic
b. Logical
c. Relational
2. The _________ operators determine the relation between two or more operands.
a. Logical
b. Relational
c. Arithmetic
3. A ___________ is an application that can be installed on a local machine or remote machine.
a. Web Server
b. Compiler
c. Interpreter
4. Literals are a _______ of characters that represent the values in a program and are stored in a variable.
a. Table
b. List
c. Sequence
5. In PHP, a variable name starts with a _____________.
a. $
b. &
c. @
E. Answer the following questions:
1. List any two advantages of PHP.
Ans: Advantages of PHP are:
a. It is free and easily available.
b. It is easy to learn.
c. PHP code can run on any operating system.
2. What are identifiers?
Ans: Identifiers are used to name the different components of a program such as variables, methods, objects, etc.
3. What is the significance of variables?
Ans: A variable is required to store the value in memory.
In PHP, variable can be declared by prefixing a $ sign before the variable name.
4. Briefly explain the rules for naming variables.
Ans: Rules for name variable are:
a. A variable name starts with a $ sign.
b. It can consists of any combination of letters, digits and underscore.
c. It can be of any length.
d. Both the uppercase and lowercase can be used as naming variable.
e. Variable names are case sensitive.
f. Variable name cannot contain space.
5. Identify the valid and invalid variable names. Give reason for the invalid ones.
_roll num, 3Term, Price_unit, new, geog-marks
Ans: _roll num – Invalid (Variable name cannot contain space)
3Term – Invalid (Variable name cannot start with number)
Price_unit – Valid (It can consists of any combination of letters, digits and underscore)
geog-marks – Invalid (Variable name cannot contain hyphen)
6. What is the difference between POST and GET methods?
Ans: GET – The information sent from an HTML form by using the GET method is visible to everyone in the browser’s address bar.
This method is not suitable for sharing sensitive information.
POST – The data submitted by this method is collected by the predefined super global variable.
In this method the data collected is not visible to anyone.
Comments
Post a Comment