Server Side Scripting (PHP): Question Bank
- Categories Server Side Scripting
PHP is a widely-used open source general-purpose scripting language. It is especially suited for web development and can be embedded into HTML. This post contains various questions in the form of true/false statements, MCQs and fill in the blanks on the topic of Server Side Scripting.
State whether the following statements are true or false.
- PHP is a widely-used open source general-purpose scripting language.
Ans. True
- PHP can be embedded into HTML.
Ans. True
- PHP runs on only Linux and windows.
Ans. False
- PHP hides the code from the user
Ans. True
- There is a need for compilation for PHP code.
Ans. False
- PHP supports a wide range of Databases.
Ans. True
- The server-side environment that runs a scripting language is termed web server.
Ans. True.
- PHP mainly focuses on client-side scripting.
Ans. False
- PHP is slower than JSP and ASP scripting language.
Ans. False
- PHP is paid scripting language.
Ans. False
- In PHP ____ is used to identify user or it’s machine.
Ans. Cookie
- In PHP, when the browser requests server page, ___ are sent along with the request.
Ans. Cookies
- A PHP ___ is used to store user information on server to track user activates.
Ans. Session
- PHP session helps ______ to maintain user information on all the PAGES.
Ans. web applications
- PHP is a case sensitive scripting language.
Ans. True
- In PHP, all keywords Classes, Functions, and User-defined functions are case-sensitive.
Ans. False
- PHP has some predefined error reporting constants to generate a warning or error notice.
Ans. True
- In PHP data types are not set in a strict sense.
Ans. True
- We can add a string to an integer without causing an error.
Ans. True
- $conn -> null is to close the database connectivity object.
Ans. True
- Cookies in PHP create track activities in the server computer.
Ans. False
- PHP can be used both to create and retrieve cookie values.
Ans. True
- Keywords, function and class names in PHP are case insensitive.
Ans. True
- The echo keyword is case sensitive.
Ans. False
- <?php and ?> special processing instruction allow users to move INTO and OUT of “PHP mode.”
Ans. True
- A PHP script cannot be placed anywhere in the HTML document.
Ans. False
- A Variable name in PHP must start with a letter or the underscore character.
Ans. True
- A Variable name can start with a number.
Ans. False
- Variable names are case-sensitive.
Ans. True.
- A variable declared within a function has a Global Scope.
Ans. False
- We can access a Global Variable $c from within a function using “GLOBAL” keyword before the variables.
Ans. True
- In PHP when a function is executed, then all of its Variables are deleted.
Ans. True
- Variables can store data of different types.
Ans. True
- Using var_dump() method in PHP we can check the data-type of variable.
Ans. True
- var_dump() method in PHP gives the same output for each type of data type.
Ans. False
- PHP method var_dump() gives actual digit for ‘Boolean’ data type.
Ans. False
- Comments are ignored during execution.
Ans. True
- The ‘If statement’ in PHP executes a piece of code conditionally.
Ans. True
- PHP function str_replace() replaces all characters with some other characters in a string.
Ans. False
- The substr() function returns a part of strig.
Ans. True
- PHP built-in functions can be called directly to perform a specific task.
Ans. True
- An array is a variable that can hold more than one value at a time.
Ans. True
- The index can be assigned manually.
Ans. False
- In associative array, instead of index location, we can refer values with the help of keys.
Ans. True
- PHP can handle multiple levels of single dimensional array.
Ans. False
- GET has no limits on the amount of information to send.
Ans. False
- PHP GET method can be best for sending passwords online.
Ans. False
- Information sent from a Form with the POST method is invisible to everyone.
Ans. True
- POST Method in PHP does not make it possible to bookmark the page.
Ans. True
- ‘->’ is used to execute SQL statement.
Ans. True
- PHP POST Method helps us to know if the button is clicked or not.
Ans. False
- In PHP try/catch block the code to handle the error can be place in catch{ } block.
Ans. True
- StrLength() function returns the length of a string.
Ans. False
- Strrev() function reverses a string.
Ans. True
- Strpos() function returns a string
Ans. True
- trim() function adds white space and other pre-defined characters from both sides of a string
Ans. True
- Multidimensional arrays are the ones with named keys.
Ans. False
- The len() function is used to return the length of an array.
Ans. False
- We cannot create our own functions in PHP.
Ans. False
Fill in the following blanks:
- PHP is especially suited for ____ results.
Ans. web development
- The server side environment running a scripting language is called _______
Ans. web server
- ____ is compatible with almost all servers used today.
Ans. PHP
- PHP is easy to learn and runs efficiently on the ___ side.
Ans. Server
- PHP files have ___ extension.
Ans. .php
- _____ keyword displays text on a web page.
Ans. echo
- ______ is a symbol or name that stands for a specific value.
Ans. variable
- A variable stands with the _____ sign followed by variable name.
Ans. $
- User’s request to generate _____ pages is fulfilled by running a script directly on the web server.
Ans. dynamic HTML
- PHP, JAVA AND JSP and Python examples of ______ programming languages.
Ans. server-side
- _____ scripting is used to collect form data, generate dynamic page content, or send and receive cookies.
Ans. Server-side
- PHP provides access logging by creating the ____ of recent accesses for the user.
Ans. summary
- PHP is most popular and frequently used worldwide ____ scripting language.
Ans. server-side
- PHP is platform ____ scripting language.
Ans. Independent
- In PHP try/catch block, the part of code which may be erroneous can be put in ___ block.
Ans. try{ }
- In PHP PDO exception class is used to throw errors due to____.
Ans. Database connectivity
- The PHP code is usually enclosed in special processing instruction ____.
Ans.
- The ____ names in PHP are case sensitive.
Ans. variable
- ____ is a symbol or name that stands for a value.
Ans. Variable
- ____, _____ and ____ are three different variable scopes in PHP.
Ans. Local, global, static
- _____ variable can only be accessed outside a function.
Ans. Global
- ____ PHP Variable can only be accessed within that function.
Ans. Local Scope
- PHP method var_dump() gives the length of string for ____ data type.
Ans. String
- ____ are the statements in PHP code, which are not visible in the output of the program.
Ans. Comments
- The ‘If statement’ in PHP allows programmer to make decisions based on one or more____.
Ans. Conditions
- ___ are used to execute the same block of code repeatedly as long as a certain condition is satisfied.
Ans. Loops
- ____ loop only works for array in PHP.
Ans. Foreach
- The PHP predefined function ____ returns the length of a string.
Ans. strlen()
- The PHP predefined function str_word_count() is used to count the number of words in____.
Ans. a string
- A ____ is a series of characters.
Ans. String
- _____ is a block of statements that can be used repeatedly in a program.
Ans. Function
- PHP Method GET may be used for sending ____ data.
Ans. non- sensitive
- ___ method in PHP supports multi-part binary input while uploading files to server.
Ans. POST
- ____ method in PHP is used to check whether variable has value or not.
Ans. isset()
- ___ exceptions are used to handle errors in PHP.
Ans. PDO
- Anything you do with PDO should be wrapped in a ___ block.
Ans. try/catch
- An ___ stores multiple values in one single variable.
Ans. Array
- ____, ____ and ____ arrays are the types of array.
Ans. Indexed, Associative, Multi-Dimensional
- The count() function in PHP is used to return the ___ of an array.
Ans. Length
- A ____ array is an array containing one or more arrays.
Ans. Multidimensional
- _____ function converts a string to lowercase
Ans. strtolower()
- ______ converts the first character of each word in a string to uppercase.
Ans. ucwords()
- Arguments are specified after the ____ name, inside the parentheses.
Ans. function
- When browsers request server page, ____ are sent along with the request.
Ans. cookies
Multiple Choice Questions:
- A ____ is a computer system that serves as a central repository of data and programs.
- Client
- Server
- Admin
- User
Ans. 2
- PHP supports variable usage without declaring its____.
- name
- data type
- function
- none of above
Ans. 2
- A PHP file normally contains HTML tags, and some ____scripting code.
- Java
- Ruby
- Python
- PHP
Ans. 4
- <?php and ?> allows to embed ___code within PHP code.
- Java
- HTML
- PHP
- None of above
Ans. 2
- All the PHP files have extension ____.
- ‘.txt’
- ‘.java’
- ‘.php’
- ‘.html’
Ans. 3
- Variables in PHP are used for storing____.
- Numeric values
- Characters
- Memory addresses
- All of above
Ans. 4
- In PHP, a variable starts with the ____ sign.
- @ (At Symbol )
- % (Percent)
- $ (Dollar)
- ? (question mark)
Ans. 3
- A variable declared outside a function has a ___ scope.
- Local
- Global
- Static
- None of above
Ans. 2
- var_dump() method in PHP gives true/false for ___ data type.
- String
- Integer
- Boolean
- Float
Ans. 3
- A Single-line comment is possible if we add ___ before a statement in PHP.
- //
- #
- Both of above
- None of above
Ans. 3
- A cookie is a small text file that the ___ sends on the user’s computer.
- Client
- Server
- Database
- Internet
Ans. 2
- _____ helps web applications to maintain user information on all pages.
- Session
- Presentation
- Cookie
- None of above
Ans. 1
- PHP function ____ converts a string to lowercase.
- strrev()
- substr()
- strtolower()
- None of above
Ans. 3
- PHP function substr_count() counts the number of times ___ occurs in a string.
- Substring
- Word
- Blank Space
- Number
Ans. 1
- PHP function ucwords() is used to convert the first character of each word in a string to____.
- Sentence case
- Uppercase
- Lowercase
- All of above
Ans. 2
- ____ arrays are arrays that use named keys instead of index to identify record/value.
- Indexed
- Associative
- Multi-Dimensional
- None of above
Ans. 2
- PHP ___ method also has limits on the amount of information to send.
- GET
- POST
- Both of above
- None of above
Ans. 1
- A multiline comment can be added in PHP via:
- //
- #
- $
- /* and */
Ans. 4
- _____ are used to execute the same block of code repeatedly as long as a certain condition is satisfied.
- Variable
- Loops
- Object
- None of above
Ans. 2
- _____ method is used to send form data.
- HTTP POST
- FTP POST
- STP POST
- None of above
Ans. 1
- Index in arrays always starts with ___.
- 1(one)
- 0(zero)
- -1(minus one)
- Any number
Ans. 2