• Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

Have any question?

(+91) 98222 16647
info@simplycoding.in
RegisterLogin
Simply Coding
  • Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

Server Side Scripting

Server Side Scripting (PHP): Notes

  • Categories Server Side Scripting

PHP is a widely used open source server-side programming language which runs on various platforms. This post contains notes on the chapter in a question-answer format for easier comprehension.

  1. Name a few programming languages for server-side programming.

Ans.

  • PHP
  • Python
  • Java and JSP
  1. What are the features of PHP?

Ans.

  • 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 language e.g. JSP and ASP.
  • Open source: User do not need pay for use of PHP. You can freely download and use.
  • Platform independent: PHP code can be run on any platform like Linux, Unix, MAC OS X, Windows.
  • Case sensitive: PHP is case sensitive scripting language while declaration of variables and its use in the program. In PHP, all keywords Classes, Functions and User-defined functions are not case-sensitive.
  • Error reporting: PHP have some predefined error reporting constants to generate a warning or error notice.
  • Real-time access monitoring: PHP provides access logging by creating the summary of recent accesses for the user.
  • Loosely typed language: PHP supports variable usage without declaring its data type. It will be taken at the time of execution based on the type, data has its value.
  1. Write the steps to execute a PHP Program.

Ans.

  1. Type the program and save it as “.php”extension using any text editor (for e.g. “HelloWorld.php”).
  2. Create folder servers root directory. Like PHP_ folder in /var/ www/html.
  3. Save the ‘.php’ file in root directory folder. E.g ‘HelloWorld ‘ file in “PHP_ folder” folder.”
  4. Go to browser and type “http://localhost/folder_name/”inurl bar.
  5. Click on ‘.php’ file.

Eg. “http://localhost/folder_name/” and click on “HelloWorld.php” file.

  1. What are PHP Variables?

Ans.

  • Variable is a symbol or name that stands for a value.
  • Variables are used for storing values such as numeric values, characters, character strings, or memory addresses, so that user can be used in any part of the program.
  1. Write a note on the Rules for declaring PHP Variable.

Ans.

  • 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.
  1. List the all data types that PHP language can support.

Ans.

Data Types supported by PHP:

  • String
  • Integer
  • Float
  • Boolean
  • Array
  • NULL
  1. What are comments in PHP?

Ans.

  • Comments are the statements in PHP code which are not visible in the output of the program.
  • It is ignored during execution
  1. How do we stop deleting local variable after function execution?

Ans.

  • When a function is executed in PHP, then all of its variables are deleted.
  • In some cases, if user a wants a local variable not to be deleted then the use of “STATIC” keyword is must.
  1. When do we use if-else statements?

Ans.

  • The if-else statement is used when the programmer has to make a decision based on either this or that conditions.
  • Syntax:

if(condition)

{

   Statement;

}

else

{

   Statement;

}

  1. What is the use of the If statement in PHP?

Ans.

  • The ‘If statement’ allows programmer to make decision, based on one or more conditions; and execute a piece of code conditionally.
  • SYNTAX :

if(condition)

{

block of statement;

}

  1. What is used of the PHP function strpos()?

Ans. PHP function strpos() searches for a specific text within a string and returns the character position of the first match. If no match is found, then it will return false.

  1. Why do we use trim() function in PHP?

Ans. PHP function trim() is used to remove whitespace and other predefined characters from both sides of a string.

  1. What is an array and how we can create it in PHP?

Ans.

  • An array is a special variable, which can hold more than one value at a time.
  • It can store multiple  values in one single variable.
  • Syntax :

$a = array( values )

  1. What are different types of arrays?

Ans.

Three types of arrays in PHP are:

  • Indexed Arrays –arrays with a numeric index
  • Associative Arrays –arrays with named keys
  • Multi-Dimensional Arrays –arrays containing one or more arrays
  1. What is an index array?

Ans. The index can be assigned automatically (index always starts at 0).

Syntax :

$a = array( value1, value2, …, value n)

  1. What is an associative array?

Ans. Associative arrays are arrays that use named keys instead of index to identify record/value.

Syntax:

$a = array( key1 => value1, key2=>value2, …,key n => value n)

  1. What are PHP User Defined Functions?

Ans. A user-defined function declaration starts with the word function.

Syntax :

function functionName()

{

     code to be executed;

}

  1. Write key the difference between GET and POST Method.

Ans.       

$_GET is an array of variables passed via the URL parameters.

$_POST is an array of variables passed via the HTTP post method.

  1. Write difference between GET and POST Method in PHP.

Ans.

GET Method

POST Method

      i.         Information sent from a form with the GET method is visible to everyone

      i.         Information sent from a form with the POST method is invisible to everyone

     ii.         It has limits on the amount of information to send.

     ii.         POST has no limits on the amount of information to send

    iii.         GET may be used for sending non- sensitive data

    iii.         POST may be used for sending sensitive data.

  1. Write a short note on POST.

Ans.

  • Information sent from a form with the POST method is invisible to everyone.
  • POST Method has no limits on the amount of information to send.
  • POST method supports advanced functionality such as support for multi-part binary input while uploading files to server.
  • The variables are not displayed in the URL so it is not possible to bookmark the page.
  1. How do we create Database Connection object in PHP?

Ans.

  • Example: $conn = new PDO($servername, $username, $password);
  • First, we connect PHP with PostgreSQL server.
  • The above statement creates connectivity object ‘$conn’ with three parameters as shown below:
  • Server host name or ip address and database name
  • Database username
  • Database password
  1. What is a session in PHP?

Ans.

  • PHP session is used to store user information on server to track user activities.
  • It helps web applications to maintain user information on all the pages.
  • If user logs in to their Gmail account, the session helps us to access the Youtube account also.
  1. When do we use loop structure in PHP?

Ans.

  • Loops are used to execute the same block of code repeatedly as long as a certain condition is satisfied.
  • Syntax :

for(initialisation;condition;incrementation or decrementation)

{

Statement;

}

  1. What is the use of foreach loop?

Ans.

  • The foreach loop works only on arrays, and is used to loop through each key/value pair in an array.
  • Syntax :

foreach ($array as $value)

{

code to be executed;

}

  • Share:
author avatar
Simply Coding

Previous post

Server Side Scripting (PHP): Question Bank
September 29, 2020

Next post

E-Commerce and E-Governance: Notes
October 5, 2020

You may also like

php q
Server Side Scripting (PHP): Question Bank
28 September, 2020

Leave A Reply Cancel reply

You must be logged in to post a comment.

Categories

  • Uncategorized
  • Programs
    • Python
    • Java
  • Problems
    • Python
    • Java
    • Web Development
      • Internet
    • Emerging Technologies
  • Notes
    • General
    • QBasic
    • MS Access
    • Web Development
      • XML
      • HTML
      • JavaScript
      • Internet
    • Database
    • Logo Programming
    • Scratch
    • Emerging Trends
      • Artificial Intelligence
      • Internet of Things
      • Cloud Computing
      • Machine Learning
    • Computer Fundamentals
      • Computer Networks
      • E-Services
      • Computer Hardware
    • Python
    • Java
  • School
    • ICSE
      • Computers Class 9
        • Java Introduction
        • Tokens & Data Types
        • Java Operators
        • Math Library
        • if & switch
        • For & While
        • Nested loops
      • Computer Class 10
        • Sample Papers
        • OOPS concepts
        • Functions in Java
        • Constructors
        • Arrays in Java
        • Strings in Java
    • SSC
      • IT Class 11
        • IT Basics
        • DBMS
        • Web Designing
        • Cyber Laws
      • IT Class 12
        • Web Designing
        • SEO
        • Advanced JavaScript
        • Emerging Tech
        • Server Side Scripting
        • E-Com & E-Gov
      • Computer Science 11
      • Computer Science 12
    • CBSE
      • Computer 9
        • Basics of IT
        • Cyber Safety
        • Scratch
        • Python
      • Computer 10
        • Sample Papers
        • Networking
        • HTML
        • Cyber Ethics
        • Scratch
        • Python
      • Computer Science 11
        • Computer Systems
        • Python 11
          • Python Basics
          • Python Tokens
          • Python Operators
          • Python if-else
          • Python loops
          • Python Strings
          • Python List
          • Python Tuple
          • Python Dictionary
          • Python Modules
        • Data Management
      • Computer Science 12
        • Sample Papers
        • Python 12
          • Python Functions
          • Python File Handling
          • Python Libraries
          • Python Recursion
          • Data Structures
        • Computer Networks
        • Data Management
    • ISC
      • Computer Science 11
        • Introduction to Java
        • Values & Data Types
        • Operators
        • if & switch
        • Iterative Statements
        • Functions
        • Arrays
        • String
        • Data Structures
        • Cyber Ethics
      • Computer Science 12
        • Sample Papers
        • Boolean Algebra
        • OOPS
        • Wrapper Classes
        • Functions
        • Arrays
        • String
Simply Coding Computer Courses for School                Privacy Policy     Terms of Use     Contact Us

© 2021 Simply Coding

Login with your site account

Lost your password?

Not a member yet? Register now

Register a new account

Are you a member? Login now