Fill in the blanks.
(1) PHP is __________ side scripting language.
Answer : Server
(2) PHP is _________ language i.e. there is no need for compilation.
Answer : interpreted
(3) A variable starts with __________ sign followed by variable name.
Answer : $
(4) An _________ is a variable, which can hold more than one value at a time.
Answer : array
(5) Information can be passed to functions through ___________.
Answer : arguments
State True/False
(1) PHP is platform dependent scripting language.
True
False
Answer : False
(2) $_POST is an array of variables passed via the URL parameters.
True
False
Answer : False
(3) A Function is a block of statements that can be used repeatedly in a program.
True
False
Answer : True
(4) PHP cannot be embedded along with HTML tags.
True
False
Answer : False
(5) GET should NEVER be used for sending sensitive information.
True
False
Answer : True
Multiple Choice Question (1 correct)
(1) The program file of PHP havev _________ extension.
.asp
.php
.js
.txt
Answer : .php
(2) A variable declared ___________ a function has global scope.
outside
anywhere
inside
none
Answer : outside
(3) The ____________ function returns a part of a string.
trim()
ucwords()
substr()
strpos()
Answer : substr()
Multiple Choice Question. (2 correct)
(1) The _________ and _________ are valid data types in PHP.
a) Double
b) Varchar
c) Integer
d) Array
e) Biglnt
Answer : Integer and Array
(2) Single line comment in PHP is possible using _______, __________.
a) //
b) /* */
c) #
d) <!-- -->
e) $
Answer : // and /* */.
Multiple Choice Question. (3 correct)
(1) ln PHP, three types of arrays are ________, _________, __________.
a) Indexed
b) Simple
c) Associative
d) Multidimensional
e) Complex
f) General
Answer : Indexed, Associative, Multidimensional.
(2) The scope of variable can be _______, _______, ______.
a) local
b) global
c) universal
d) static
e) final
f) outside
Answer : local, global, static.
Brief Questions.
(1) Explain any two features of PHP?
Answer :
PHP is the most popular and frequently used worldwide server-side scripting language.
Following are features of PHP:
- Simple: It is very simple and easy to use, as compared to other scripting languages.
- Interpreted: It is an interpreted language, i.e. there is no need for compilation.
- Faster: It is faster than other scripting languages e.g. JSP and ASP.
- Open Source: Open source means you need not pay for use of PHP. You can freely download and use it.
- Platform Independent: PHP code will be run on every platform, Linux, Unix, Mac OS X, Windows.
(2) What are the rules for declaring variables in PHP?
Answer :
Following are the rules for declaring variables in PHP:
- A variable starts with the $ sign, followed by the name of the variable
- A variable name must start with a letter or the underscore character
- A variable name cannot start with a number
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and_)
- Variable names are case-sensitive ($age and $AGE are two different variables)
(3) What is server-side scripting?
Answer :
- A server is a computer system that serves as a central control of data and programs shared by clients.
- The server-side environment that runs a scripting language is termed a web server.
- A user's request is fulfilled by running a script directly on the web server.
- It is used to provide interactive websites.
- Programming languages for server-side programming are PHP, Python, JSP.
(4) List the supported data types in PHP.
Answer :
- String: A string is a sequence of characters. A string can be any text inside quotes. You can use single or double-quotes.
- Integer: An integer data type is a non-decimal number between -2,147,483,648 and 2,147,483,647.
- Float (floating point numbers): A float (floating-point number) is a number with a decimal point or a number in exponential form.
- Boolean: A Boolean represents two possible states. TRUE or FALSE.
- Array: An array stores multiple values in one single variable.
- NULL: Null is a special data type which can have only one value NULL. A variable of data type NULL is a variable that has no value assigned to it.
(5) Explain any two string manipulation function.
Answer :
Function | Description |
strlen() | Returns the length of a string (i.e. total no. of characters) |
str_word_count() | Counts the number of words in a string |
strrev() | Reverses a string |
strpos() | Searches for a specific text within a string and returns the character position of the first match and if no match is found, then it will return false |
str_replace() | Replaces some characters with some other characters in a string |
No comments:
Post a Comment