PHP Imp
PHP Imp
Iechnology (Sene)
Write Programs for the following
1 using torm.
Wnte a THP code which calculates square of any number
Ans. : Refer PHP Extra programs for practice Program No 3
2
Write a PHP code to count no. of words in the given string
Ans. : Refer PHP Extra programs for practice Program No 13
3.
Create a website with two PHP webpage in which each webpage is connected
The first Page of the website contains two form fields for taking 'name
password' from users. On onclick event, details of forms should be displayed andon
second webpage.
Ans. : Refer PHP Extra programs for practice Program No 14
Fillin the Blanks
5.2 Server Side Scripting
1. A 1S a Computer system that serves as a central repository of data and
programs.
Ans. : Server
2. The server side environment that runs a scripting language is called
Ans, : Web Server
3. PHP is .sidescripting language. (March 2022)
Ans. : Server
5.3 Features of PHP
4. PHPis ....... l.nguage, there is no need for compilation.
Ans. :Interpreted
5.4 FirstSample code of PHP
5. PHP files have extension (March 202
Ans. : .php
keyword is used to display text on web page. (March 2022
Ans. :echo
7. . is asymbol or name that stands for a value.
Ans. : Variable
8. A variable starts with the sign followed by the name of the variable.
(March 2022
Ans. :S
9. A variable nane cannot start with a
Ans,: Global
Avariable declared outside afunction has a .........scope and can only be accessed
outside a function.
(March2022
Ans Global accessed
M. Avariable declared within a function has a........SCope and can only be
(March 2022
within that function.
Ans. : Locai
TI'S nformation Technology (Science) Server-Side Scripting (PHP)
5-5
Ans.:if
14. The .....*..Statement allows programmer to make decision based on either tnIs o
that condition.
Ans. :if else
15. .are used to execute the same block of code
condition is satisfied. repeatedly as long as certani
Ans. : loop
16.
Ans. : foreach
.loopworks only on arrays.
17. .functions returns the length of a string. (March 2022)
Ans. :strlen)
18. ...
3.
is an aray Vanables passed via the URL parameters. (March 2022)
Ans.:$ POST
Intormation sent trOm a formm
4. with method is visible to everyone.
Ans.:GET
method may be used for sending non (March 2022)
Ans. : GET sensitive data.
Intormation sent troma form witlh
Ans. : POST method is invisible to everyone.
method has no limits on the amount of
Ans.: POST intormation to send.
object helps to connect PHP code with
Ans. :PD00 any database server.
49. method in PHP is used to check whether
Ans. :isset() variable has value or not.
50. A......is asmall text file that
Ans. : Cookie
the server sends on the user's computer.
51. .is used to identify user or its
computer. machine and track activities created on the user
Ans. : Cookie
When browser requests server page
.are sent along with the request.
Ans. :cookie (March 2022)
53. .is used to store user
Ans. :session
information on server to track user activities.
54. ..... helps web application tomaintain user
information on all the pages.
Ans. : Session (March 2022)
True or False
Ans. : True
56. $_GET and $_POST syperglobals which means that they are never accessible.
Ans. : False
57.
$_GET is an array of variables passed via the URL parameters.
Ans. : True
POST method. (March 2022)
58. $_POST is an array of variables passed via the HTTP
Ans.: True
59. Information sent from aform with GET method is not visible to everyone.
(March 2022)
Ans. :False
(March 2022)
60. GET has limits on the amount of information to send.
Ans. : True
61. GET should NEVER be used for sending passwords or other sensitive information.
Ans.: True
62. Information sent from a form with POST method is invisible to everyone.
(March 2022)
Ans.: True
63. POST has limits on the amount of information to send. (March 2022)
Ans.: False
64. isset() method in PHP is used tocheck whether variable hasvalue or not.
(March 2022)
Ans. : True
65. Acookie is asmall text file the client sends on the user's computer.
Ans.: False
66. When browser requests server page, cookies are sent along with the request.
Ans. :True
TPS Information Technology (Science) 5-12
Server-Side Scripting (PHp,
67.
Cookies storevisited page on browser tooptimize search.
Ans. :True (March 2022
68.
DeSSion is used to store user information on server to track user activities.
Ans. :True
69.
Session helps web application to maintain user information on all the pages.
Ans. :True
70. PHP Data Object helps us to connect PHP code in Uniform Method of
access to
multiple databases. (March 2022)
Ans. :True
21. ..are used to execute the same block of code repeatedly as long as a certain
condition is satisfied. (March 2022)
(a) Variable (b) Method (c) Object (d) loops
Ans. : (d) Ans
22. .loop works only on arrays. (March 2022
(a) for next (b) for (c) foreach (d) forone
Ans. : (c)
23. ........function returns the length ofa string. (March 202 Ans
(a) strrev) (b) strlen() (c) strlength) (d) substr()
Ans. : (b)
24. .....function counts the number of words in a string.
(a) strlen() (b) str_word_count()
(c) substr() (d) trim()
Ans. : (b)
functionreverses a string. (March 2022
28.
(a) strrev() (b) trim() (c) UCwords() (d) strops()
Ans. :(a)
(March 2022)
26. function searches for aspecifictext within a string.
substr() (b) strrev() (c) strpos() (d) str replace()
(a)
Ans. : (c)
Server-Side Scripting (PHP)
TPSInformation Technology (Science) 5-15
6. ..is an array of variables passed via the URL parameters. (March 2022)
(a) $GET (b) #GET (c) -GET (d) @ GET
Ans.: (a)
..is an array of variables passed via the HTTP POST method. (March 2022)
(a) $POST (b) $_POST (c) @_POST (d) #_POST
Ans. : (b)
Information sent from aform with .....nethod isvisible to everyone.
(a) POST (b) GET (c) HTTP (D) FTP (March 2022)
Ans.: (b)
49. Information sent from a form with method is invisible to everyone.
(a) POST (b) GET (c) HTTP (d) FTP
Ans. : (a)
B0. .NEVERbe used for sending sensitive information. (March 2022)
(a) POST (b) HTTP (c) GET (d) FTP
Ans. : (c)
.method in PHP is used to check whether variable has value or not.
(a) outset() (b) inset() (c) noset() (d) isset() (March 2022)
Ans. : (d)
52
A....isa small text file that the server sends on the user's computer.
(a) Cookie (b) session
(c) Presentation (d) Method
Ans.: (a)
53.
.aresent along when browser requests server pages.
a) Cookie (b) Session (c) Method (d) Server
Ans. :(a)
54. i.*. 1S used to store information on server to track user activitIes.
(a) Cookie (b) session (c) Presentation (d) Object
Ans.:(b)
TPS Information Technology (Science) 5-18 Server-Side Scripting (PHh
55.
.helps web application to maintainuser information on all the pages.
(a) Session (b) presentation
(c) Cookie (d) object
Ans. :(a)
7.
A variable starts with the sign folowed by of the variable.
(a) $ (b) # () name (d) value
Ans.: (a),(c)
A variable declared ...a function has GLOBAL sCOPE and a variable declared
.a function has LOCAL SCOPE.
(a) inside (b) outside (c) within (d) between
Ans. : (b), (c)
Followingare the data types used in PHP
(a) Boolean (b) Text (c) Number (d) Array
Ans. :(a), (d)
18. Control structures in PHP are (March 2022)
(a) for (b) if statement
(c) for each (d) ifelse statement
Ans. : (b), (d)
11. Loop structure in PHP are (March 2022)
(a) for (b) for each (c) if (d) if else
Ans. :(a), (b)
12. Comments in PHP is possible in following ways. (March 2022)
(a) // (b) \\ (c) /* and */ (d) /# and #/
Ans. : (a), (c)
13. Comments are of .and type.
(a) Single line (b) No line (c) Two line (d) Multi-line
Ans. : (a), (d)
14 Following are the pre defined functions in PHP to manipulate string. (March 2022)
(a) trim) (b) substr() (c) length) (D) strreverse()
Ans. :(a), (b)
5.7 PHP User Defined Functions