NotesB.Sc ITProgramming in PHP
BSIT401

Programming in PHP Notes

Program:B.Sc IT
Semester:Semester 4
Credits:5
Units:4 Units

Subject Overview

Programming in PHP covers PHP fundamentals and control structures, functions/string manipulation/arrays, forms and file/database handling with MySQL, and cookies/sessions and advanced PHP techniques. A 5-credit core theory paper.

Unit-wise Syllabus

4 units — open any unit for detailed topic-wise notes, diagrams and important exam questions

  • Evolution of PHP
  • PHP scripting basics
  • receiving user input
  • PHP data types
  • operators
  • variable manipulation and scope
  • control structures (if/elseif, switch, while, do-while, for loops, nesting)
ProcessHow a PHP page is served
  1. 1Browser requests page.php
  2. 2Web server passes it to the PHP engine
  3. 3PHP runs the script

    May query MySQL

  4. 4Output is plain HTML
  5. 5Browser displays the HTML

Study guide

PHP is a server-side scripting language for dynamic websites. You study its evolution, scripting basics, receiving user input, data types, operators, variable manipulation and scope and control structures (if-elseif, switch, while, do-while, for, nesting). Run every small script on a local server to see the output.

Read Unit 1 notes
  • Function definition/creation/return values
  • user-defined and dynamic functions
  • default arguments
  • string formatting/comparison/matching
  • index-based and associative arrays
  • array looping with each() and foreach()
ComparisonIndexed vs associative arrays
Indexed
Associative

Keys

Numbers from 0

Named strings

Example

$a = ["red", "blue"];

$a = ["name" => "Ana"];

Access

$a[0]

$a["name"]

Loop

for or foreach

foreach ($a as $k => $v)

Study guide

You study functions (definition, return values, user-defined and dynamic functions, default arguments), string formatting, comparison and matching, and arrays: indexed and associative, with looping through foreach. Practise array and string functions; they are used in almost every PHP program.

Read Unit 2 notes
  • Working with forms and superglobal variables
  • importing and accessing user input
  • opening/copying/renaming/deleting files
  • working with directories
  • generating images with PHP
  • MySQL database connectivity
  • DML operations (insert, delete, update, select)
  • joins (cross, inner, outer, self)
ComparisonSQL joins
Returns
Typical use

INNER JOIN

Only matching rows in both tables

Orders with their customers

LEFT JOIN

All left rows, plus matches

Customers even without orders

CROSS JOIN

Every combination of rows

Generating all pairs

SELF JOIN

A table joined to itself

Employees and their managers

Study guide

You study forms and superglobals, importing user input, file operations (open, copy, rename, delete), directories, generating images, MySQL connectivity, insert, delete, update and select operations and joins. Build a small form-to-database application end to end.

Read Unit 3 notes
  • Setting and deleting cookies
  • session creation and destruction
  • encoding/decoding session variables
  • FTP/SMTP server introduction
  • math functions
  • file upload/download
  • email with PHP
  • error tackling and debugging
  • PHP project requirements analysis
ComparisonCookies vs sessions
Cookie
Session

Stored on

The browser

The server

Security

Less: user can see and edit

More secure

Size

Small (about 4 KB)

Larger

Lifetime

Until its expiry date

Until the browser closes or timeout

Study guide

You study cookies, sessions, encoding and decoding session variables, FTP and SMTP basics, math functions, file upload and download, sending email, error handling and debugging and the requirements analysis for a PHP project. Use sessions to build a simple login system.

Read Unit 4 notes

Why Programming in PHP Matters

PHP and MySQL power a very large share of websites, including WordPress, so PHP skills lead directly to web development and freelance work.

How to Prepare for Programming in PHP

  • Build a small database-driven project such as a login system or blog.
  • Always validate and sanitise user input.
  • Learn the difference between GET and POST and between cookies and sessions.

Programming in PHP: Frequently Asked Questions

What is the difference between cookies and sessions?

Cookies store small data in the user's browser, while sessions store data on the server and identify the user with a session ID.

Which database is commonly used with PHP?

MySQL is the most common database used with PHP.

Want the Complete Notes & Past Papers?

WhatsApp us and we'll send you the full notes, question banks, and previous year papers for Programming in PHP.