ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Web Engineering
    ITEC3111
    Progress0 / 24 topics
    Topics
    1. Web programming languages (HTML5, CSS3, JavaScript, PHP/JSP/ASP.Net)2. HTML53. CSS34. JavaScript5. PHP6. JSP7. ASP.Net8. Design principles of Web based applications9. Web platform constraints10. Software as a Service (SaaS)11. Web standards12. Responsive Web Design13. Web Applications14. Browser/Server Communication15. Storage Tier16. Cookies and Sessions17. Input Validation18. Full stack state management19. Web App Security - Browser Isolation20. Network Attacks and Session Attacks21. Large scale applications22. Performance of Web Applications23. Data Centers24. Web Testing and Web Maintenance
    ITEC3111›PHP
    Web EngineeringTopic 5 of 24

    PHP

    3 minread
    530words
    Beginnerlevel

    🐘 PHP (Hypertext Preprocessor)


    📌 1. Definition

    PHP is a server-side scripting language used to create dynamic and interactive web pages. It runs on the web server and sends processed output (HTML) to the browser.


    🌐 2. How PHP Works (Diagram Description)

    👉 Draw this in exam:

    Browser → Request → Web Server (PHP Code)
                     ↓
               Process Logic
                     ↓
              Send HTML Response → Browser
    

    ✔ PHP code is executed on server, not visible to user.


    🧱 3. Basic PHP Syntax

    <?php
    echo "Hello World";
    ?>
    

    🔑 Key Points

    • PHP code starts with <?php and ends with ?>
    • Each statement ends with ;
    • echo is used to display output

    🧠 4. Variables in PHP

    📌 Definition

    Variables store data values.

    <?php
    $name = "Ali";
    $age = 20;
    ?>
    

    ⭐ Rules

    • Starts with $
    • Case-sensitive
    • No need to declare data type

    🔢 5. Data Types

    • String
    • Integer
    • Float
    • Boolean
    • Array
    • Object
    • NULL

    ➕ 6. Operators

    • Arithmetic: + - * / %
    • Assignment: =
    • Comparison: == != > <
    • Logical: && || !
    <?php
    $x = 10 + 5;
    ?>
    

    🔀 7. Control Statements

    1. If-Else

    <?php
    if ($x > 10) {
      echo "Greater";
    } else {
      echo "Smaller";
    }
    ?>
    

    2. Loops

    <?php
    for ($i = 0; $i < 5; $i++) {
      echo $i;
    }
    ?>
    

    🔧 8. Functions

    <?php
    function greet() {
      echo "Hello!";
    }
    greet();
    ?>
    

    🌍 9. Forms Handling (Important)

    HTML Form

    <form method="post">
      Name: <input type="text" name="name">
      <input type="submit">
    </form>
    

    PHP Processing

    <?php
    $name = $_POST['name'];
    echo $name;
    ?>
    

    🗄️ 10. Working with Database (MySQL)

    <?php
    $conn = mysqli_connect("localhost", "root", "", "test");
    ?>
    

    🔑 Steps

    1. Connect database
    2. Execute query
    3. Fetch data

    📂 11. Superglobals (Important)

    • $_GET
    • $_POST
    • $_SERVER
    • $_SESSION
    • $_COOKIE

    🔐 12. Sessions & Cookies

    Session Example

    <?php
    session_start();
    $_SESSION["user"] = "Ali";
    ?>
    

    Cookie Example

    <?php
    setcookie("user", "Ali", time()+3600);
    ?>
    

    📊 13. PHP Execution Flow

    User Request → Server → PHP Execution → Database → Response (HTML)
    

    ⚠️ 14. Important Rules

    ✔ PHP runs on server-side ✔ File extension is .php ✔ Can be embedded in HTML ✔ Use $_POST for secure data transfer ✔ Always validate user input


    📈 15. Advantages

    • Open-source
    • Easy to learn
    • Database support
    • Platform-independent
    • Fast execution

    ❌ 16. Limitations

    • Less secure if not coded properly
    • Slower than some modern frameworks
    • Mixing HTML & PHP can reduce readability

    ❓ 17. Likely Exam Questions

    Short Questions

    1. Define PHP.
    2. What are PHP variables?
    3. List PHP data types.
    4. What are superglobals?
    5. What is session?

    Long Questions

    1. Explain PHP syntax with example.
    2. Describe form handling in PHP.
    3. Explain PHP with database connectivity.
    4. Discuss sessions and cookies.
    5. Compare PHP with JavaScript.

    📝 18. Summary / Quick Revision

    • PHP = Server-side language

    • Used for:

      • Dynamic pages
      • Form handling
      • Database interaction
    • Key features:

      • Variables ($)
      • Superglobals
      • Sessions & Cookies

    👉 Works with HTML + CSS + JavaScript to build full web applications.


    Previous topic 4
    JavaScript
    Next topic 6
    JSP

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time3 min
      Word count530
      Code examples0
      DifficultyBeginner