5.Server-Side Scripting (PHP) Exercise Solutions

0
मित्रांनो या पोस्टमध्ये आपण Information Technology या विषयाचा Chapter Number 5 - Server - Side Scripting (PHP) चे Exercise Solutions पाहणार आहोत. 
या Chapter मध्ये Exercise Questions पुढीप्रमाणे आहेत :- 
Q.1) Fill in the blanks.
Q.2) State True/False.
Q.3) Multiple Choice Question. (1 correct)
Q.4) Multiple Choice Question. (2 correct)
Q.5) Multiple Choice Question. (3 correct)
Q.6) Brief Questions.
Q.7) Write Programs for the following.

चला तर मग आता पाहूया Server-Side Scripting (PHP) चे Exercise Solutions :- 

HSC IT - Server - Side Scripting (PHP) Exercise Solutions Maharashtra Board


Q.1) Fill in the blanks.


1) PHP is _____ side scripting language.
Ans : Server

2) PHP is _____ language i.e. there is no need for compilation.
Ans : Interpreted

3) A variable starts with _____ sign followed by variable name.
Ans : $

4) An _____ is a variable, which can hold more than one value at a time.
Ans : Array

5) Information can be passed to functions through _____.
Ans : Arguments


Q.2) State True/False.


1) PHP is platform dependent scripting language.
Ans : False

2) $_POST is an array of variables passed via URL parameters.
Ans : False

3) A Function is a block of statements that can be used repeatedly in a program.
Ans : True

4) PHP cannot be embeded along with HTML tags.
Ans : False

5) GET should NEVER be used for sending sensitive information.
Ans : True

Q.3) Multiple Choice Question. (1 correct)


1) The program file of PHP have _____ extension.
a) .asp
b) .php
c) .js
d) .text
Ans : b) .php

2) A variable declared _____ a function has global scope 
a) outside
b) anywhere
c) inside
d) none
Ans : a) outside

3) The _____ function returns a part of a string.
a) trim()
b) ucwords()
c) substr()
d) strpos()
Ans : c) substr()


Q.4) Multiple Choice Question. (2 correct)


1) The _____ & _____ are valid datatype in PHP.
a) Double
b) Varchar
c) Integer 
d) Array
e) BigInt
Ans : c) Integer, d) Array

2) Single line comment in PHP is possible using _____, _____.
a) //
b) /**/
c) #
d) <!-- -->
e) $
Ans : a) // , c) #

Q.5) Multiple Choice Question. (3 correct)


1) In PHP, three types of arrays are _____, _____, _____.
a) Indexed
b) Simple
c) Associative
d) Multidimensional
e) Complex
f) General
Ans : a) Indexed, c) Associative, d) Multidimensional

2) The scope of variable can be _____.
a) local
b) global
c) universal
d) static
e) final
f) outside
Ans : a) local, b) global, d) static

Q.6) Brief Questions.


1) Explain any two features of PHP?
Ans : There are many features in PHP, such as - i) Simple :- It is very simple and easy to use, as compared to other scripting languages.
ii) Interpreted :- It is an interpreted language, i.e. there is no need for compilation.

2) What are the rules of declare variables in PHP?
Ans : Following are the rules for declare variables in PHP :-
i) A variable starts with the $ sign followed by the name of the variable
ii) A variable name was start with a letter or the underscore character
iii) A variable name cannot start with a number
iv) A variable name can only contain alpha-numeric characters and underscores (A-z,0-9,and _)
v) Variables names are case sensitive ($age and $AGE are two different variables)

3) What is Server Side scripting?
Ans : i) A server is a computer system that serves as a central repository of data and programs and is shared by the clients.
ii) The server-side environment that runs a scripting language is termed web server.
iii) A user's request is fullfield by running a script directly on the web server to generate dynamic HTML pages.
iv) This HTML is then send to the client browser.
v) It is usually used to provide interactive websites that interfaces with databases or other data stored on the server.
few programming languages for the server-side programming are :
- PHP
- Java and JSP
- Python

4) List the supported data types in PHP.
Ans : Variables can store data of different types and PHP support the following data types : 
i) String
ii) Integer
iii) Float
iv) Boolean
v) Array
vi) NULL

5) Explain any two string manipulation function.
Ans : Following are the few predefined functions in PHP to manipulate string :- 
i) strlen() :- Returns the length of a string (i.e. total no. of characters)
ii) str_word_count() :- Counts the number of words in a string

Q.7) Write Programs for the following.


1) Write a PHP code which calculate square of any number using form.
Ans : Code

    
<!DOCTYPE html>
<html>
<head>
  <title>Number Square Calculator</title>
</head>
<body>
  <h1>Number Square Calculator</h1>
  <form method="get" action="">
    <label for="numberInput">Enter a number:</label>
    <input type="text" name="number" id="numberInput" />
    <input type="submit" value="Calculate" />
  </form>

  <?php
  if (isset($_GET['number'])) {
    $number = $_GET['number'];
    $square = $number * $number;
    echo "<p>Square of $number is $square</p>";
  }
  ?>
</body>
</html>


2) Write a PHP code to count number of words in the given string.
Ans : Code -

    
<!DOCTYPE html>
<html>
<head>
  <title>Word Count</title>
</head>
<body>
  <h1>Word Count</h1>
  <form method="post" action="">
    <label for="textInput">Enter a string:</label>
    <input type="text" name="text" id="textInput" />
    <input type="submit" value="Count" />
  </form>

  <?php
  if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_POST['text'])) {
      $string = $_POST['text'];
      $wordCount = str_word_count($string);
      echo "<p>Number of words: $wordCount</p>";
    }
  }
  ?>
</body>
</html>


3) Create a website with two PHP web page in which each web page is connected.
The first page of the website contains two form fields for taking 'name' and 'password' from users. On click event, details of forms should be display on the second webpage.
Ans : Code - 
File name - index.php

    
<!DOCTYPE html>
<html>
<head>
  <title>User Details - Page 1</title>
</head>
<body>
  <h1>User Details - Page 1</h1>
  <form method="post" action="display.php">
    <label for="nameInput">Name:</label>
    <input type="text" name="name" id="nameInput" required />
    <br>
    <label for="passwordInput">Password:</label>
    <input type="password" name="password" id="passwordInput" required />
    <br>
    <input type="submit" value="Submit" />
  </form>
</body>
</html>

File name - display.php

    
<!DOCTYPE html>
<html>
<head>
  <title>User Details - Page 2</title>
</head>
<body>
  <h1>User Details - Page 2</h1>
  <?php
  if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_POST['name']) && isset($_POST['password'])) {
      $name = $_POST['name'];
      $password = $_POST['password'];

      echo "<p>Name: $name</p>";
      echo "<p>Password: $password</p>";
    }
  }
  ?>
</body>
</html>


अशा प्रकारे मित्रांनो आपण इयत्ता बारावी Information Technology या विषयाचा Chapter Number 5 - Server Side Scripting (PHP) याचे Exercise Solutions पहिले.
तुम्हाला या solutions ची PDF Download करण्यासाठीं पुढील लिंक वर क्लिक करा :-


पुढील Chapter चे Exercise Solutions पाहण्यासाठी "NEXT" button वर क्लिक करा. मागील Chapter चे Exercise Solutions पाहण्यासाठी "Previous" button वर क्लिक करा.


टिप्पणी पोस्ट करा

0 टिप्पण्या
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
टिप्पणी पोस्ट करा (0)
To Top