Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Pro Blog
  • Users
  • Groups
  • Unsolved
  • Solved
Collapse
Secnto AI
  1. Secnto AI
  2. Categories
  3. Virtual University
  4. CS310 - Open Source Web Application Development (PHP, PERL, CGI, Mysql)
  5. CS310 Quiz 2 Solution and Discussion
CS310 Quiz 2 Solution and Discussion
zaasmiZ
Topic thumbnail image
CS310 - Open Source Web Application Development (PHP, PERL, CGI, Mysql)
CS310 GDB 1 Solution and Discussion
zareenZ
Dear Students! Graded Discussion Board (GDB) will be launched on Monday, July 27, 2020 and it will close on Tuesday, July 28, 2020. GDB Scenario: Suppose, as a PHP developer, you are assigned a task to develop a Shopping Store Application. The application should fulfill the following requirements. · Application should be able to track the type of products users are visiting. By looking at each user’s interest, the application should suggest some related products to each user in current and future visits of store. · Application should have an option to add products into the cart and wish list but only for registered users. From cookies and PHP session or blend of both, which technique you will prefer to use for the development of required Shopping Store Application? Discuss it with precise and detailed comments. Instructions: · Your answer should not exceed 5 – 6 lines of text in justification of your selected technique. · A concise, coherent and to the point answer is preferred over lengthy comment having irrelevant details. · Answers, posted on regular lesson’s MDB or sent through email will NOT be considered in any case. Please note GDB does not have any grace day. We are giving you about a full week to prepare your comments and 48 hours to just post them. GDB comments will not be accepted through email in any case. Best of Luck!
CS310 - Open Source Web Application Development (PHP, PERL, CGI, Mysql)
CS310 Assignment 1 Solution and Discussion
M
Re: CS310 Assignment 1 Solution and Discussion Assignment No. 1 Semester: Spring 2020 CS310 – Open Source Web Application Development Total Marks: 20 Due Date: 01/06/2020 Instructions: Please read the following instructions carefully before submitting the assignment. It should be clear that your assignment will not get any credit if:  The assignment is submitted after due date.  The submitted assignment does not open or file is corrupted.  Assignment is copied (partial or full) from any source (websites, forums, students, etc) Objective: The objectives of this assignment are: • Installation and configuration of web server • Use of echo • Use of if-else statements Note: • This assignment is a Graded Assignment. • The assignment submitted through email will not be accepted. • This assignment is covering all topics of weeks 1 to 3. Assignment Submission Instructions You have to submit only .php file on the assignments interface of CS310 from your LMS account. Assignment submitted in any other format will not be accepted and will be scaled with zero marks. For any query about the assignment, contact at cs310@vu.edu.pk. Assignment In D-Mart the sale’s person is facing a problem of give change which is time consuming in rush hours. You are required to develop a web application using PHP and HTML which will make it easy for sale’ s person to find the currency notes and coins to give back to customer as change. Solution Guidelines:  A template file in PHP format is attached with this assignment file. Use this template file for the form to input cash received and bill amount. Screenshot is also given below.  Your application will deduct bill amount from cash received and display how many currency notes/coins of what value cashier should give back to customer. See second screenshot given below.  It is not compulsory to show stylish list of currency notes and coins as showing in sample output. But if you want to show in similar way then you can use template file. All necessary requirements of fancy design are already set. You just need to create list items for each note and coin. One list item is already created for you in template file.  Sample screenshot of showing different notes and coins is showing in sample screen shot which depends on how much amount we need to return. Sample Screenshots: Screenshot of given template: [image: TWqmVYW.png] Screenshot of notes and coins that need to return to customer: [image: thCJWGE.png] Best of Luck! Syllabus of assignment is all topics of week 1 to 3
CS310 - Open Source Web Application Development (PHP, PERL, CGI, Mysql)
CS310 Assignment 3 Solution and Discussion
zareenZ
Assignment No. 03 Semester: Fall 2019 CS310: Open Source Web Application Development Total Marks: 20 Due Date: January 15, 2020 Topics Covered: Topics of Week 6 to 10 General Instructions: Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:  The assignment is submitted after due date.  The submitted assignment does not open or file is corrupt.  Assignment is copied (partial or full) from any source (websites, forums, students, etc.) Note: You have to upload your assignment solution only in .doc or .docx format only. File submitted other than Microsoft Word format will get zero marks. Objective: The objective of this assignment is to provide hands on experience of: • Installing and configuring MySQL • Database and table creation • Inserting data into database (tables) Tools to use: XAMP / WAMP / Vertrigo server For any query about the assignment, contact at cs310@vu.edu.pk Problem Statement: Suppose you are working as a web developer in a financial institute. A task is given to you is take the data of sale and save into a table into a database. Table Structure: Column Name Data Type Id Numeric Name Text Region Text ClientName Text Units Numeric UnitCost Decimal Date Date Sample Data: ID Name Region ClientName Units UnitCost Date 1 Pencil East Jones 95 1.99 01/06/2018 2 Binder Central Kivell 50 19.99 1/23/2018 3 Pencil Central Jardine 36 4.99 02/09/2018 4 Pen Central Gill 27 19.99 2/26/2018 5 Pencil West Sorvino 56 2.99 3/15/2018 6 Binder East Jones 60 4.99 04/01/2018 7 Pencil Central Andrews 75 1.99 4/18/2018 8 Pencil Central Jardine 90 4.99 05/05/2018 9 Pencil West Thompson 32 1.99 5/22/2018 10 Binder East Jones 60 8.99 06/08/2018 Solution Instructions: To solve this assignment, you need to perform following steps with the help of PHP code. • Connect to MySQL server. • Create a database, the name of database should be your VU-ID. • Create table “Sales” into database. Structure of table is given above. • Insert sample data into “Sales” table. Sample data is given above. • Take screen shot of data base from MySQL and paste into solution file. What you have to submit? You have to copy/paste following into your solution file then upload solution file from your LMS account. • PHP code which will create database, table and save sample database into table. • Screen shot of “Sales” table from MySql using phpMyAdmin tool. Best of Luck!
CS310 - Open Source Web Application Development (PHP, PERL, CGI, Mysql)
CS310 Assignment 2 Solution and Discussion
zareenZ
Assignment No. 02 Semester: Fall 2019 CS310: Open Source Web Application Development Total Marks: 15 Due Date: December 02, 2019 Topics Covered: Topics of Weeks 1 to 5 Instructions: Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:  The assignment is submitted after due date.  The submitted assignment does not open or file is corrupt.  Assignment is copied (partial or full) from any source (websites, forums, students, etc) Note: You have to upload .php file which will have code of PHP. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. Objective: The objectives of this assignment are: • Understanding the use of if-else statements Note: • This assignment is a Graded Assignment. • The assignment submitted through email will not be accepted. • This assignment is covering all topics of weeks 1 to 5. Guidelines:  Code should be properly indented.  You can use the following tools/software: o Adobe Dreamweaver, Notepad o XAMP, WAMP, Vertrigo Server For any query about the assignment, contact at cs310@vu.edu.pk. Assignment Statement: Suppose, you joined NGCP (Natural Gas Company Pakistan) as a developer. The first task is given to you is create a web-based application in PHP to generate the bill of customer. User of your application will give customer id as customer_id and number of units as units through URL. Your application will read customer id and units from URL and generate the bill according to table given below. Number of Units Rate per Unit First 50 units 0.50/unit Next 100 units 0.75/unit Next 100 units 1.00/unit units above 250 1.50/unit Additional taxes on Cost of Gas is 18%. Late payment surcharge 5% payable bill. The code to reach customer_id and units from URL is already given PHP file attached with assignment. You need work on provided file and complete and missing requirements. Sample Web Page: [image: R1qXcyf.png] Submission Instructions: You have to submit single PHP file which will have all the code provided by us and PHP code you will write. BEST OF LUCK!
CS310 - Open Source Web Application Development (PHP, PERL, CGI, Mysql)
CS310 Assignment 1 Solution and Discussion
zareenZ
Topic thumbnail image
CS310 - Open Source Web Application Development (PHP, PERL, CGI, Mysql)
CS310 Assignment No. 03
 Solution and Discussion
zaasmiZ
Topic thumbnail image
CS310 - Open Source Web Application Development (PHP, PERL, CGI, Mysql)

CS310 Quiz 2 Solution and Discussion

Scheduled Pinned Locked Moved Solved CS310 - Open Source Web Application Development (PHP, PERL, CGI, Mysql)
cs310quiz 2solutiondiscussionspring 2019
19 Posts 2 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • zaasmiZ Offline
    zaasmiZ Offline
    zaasmi
    Cyberian's Gold
    wrote on last edited by
    #9

    Use …… to add table in the database
    400e9f0b-b647-4f63-9b6b-cd1c2d8011d0-image.png

    Discussion is right way to get Solution of the every assignment, Quiz and GDB.
    We are always here to discuss and Guideline, Please Don't visit Community only for Solution.
    Community Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
    [NOTE: Don't copy or replicating idea solutions.]
    VU Handouts
    Quiz Copy Solution
    Mid and Final Past Papers
    Live Chat

    zaasmiZ 1 Reply Last reply
    0
    • zaasmiZ Offline
      zaasmiZ Offline
      zaasmi
      Cyberian's Gold
      wrote on last edited by
      #10

      What SQL clause is used to restrict the rows returned by a query?
      55244ad6-5866-47d3-910c-3b933ed475c1-image.png

      Discussion is right way to get Solution of the every assignment, Quiz and GDB.
      We are always here to discuss and Guideline, Please Don't visit Community only for Solution.
      Community Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
      [NOTE: Don't copy or replicating idea solutions.]
      VU Handouts
      Quiz Copy Solution
      Mid and Final Past Papers
      Live Chat

      Zohaib MalikZ 1 Reply Last reply
      0
      • zaasmiZ zaasmi

        What SQL clause is used to restrict the rows returned by a query?
        55244ad6-5866-47d3-910c-3b933ed475c1-image.png

        Zohaib MalikZ Offline
        Zohaib MalikZ Offline
        Zohaib Malik
        wrote last edited by
        #11

        said in CS310 Quiz 2 Solution and Discussion:

        What SQL clause is used to restrict the rows returned by a query?

        The SQL clause used to restrict or filter rows based on a specific condition is the WHERE clause.

        It is placed after the FROM clause and before any grouping or sorting clauses. Only the rows that meet the specified criteria (where the condition evaluates to TRUE) will be included in the result set.

        Basic Syntax

        SELECT column1, column2
        FROM table_name
        WHERE condition;
        
        

        Examples of Usage

        Requirement SQL Example
        Exact Match WHERE city = 'London'
        Numeric Range WHERE age > 18
        Pattern Matching WHERE name LIKE 'A%'
        Multiple Conditions WHERE price < 100 AND stock > 0

        A Quick Distinction: WHERE vs. HAVING

        • WHERE: Filters individual rows before any grouping occurs.
        • HAVING: Filters groups after the GROUP BY clause has been applied.
        1 Reply Last reply
        0
        • zaasmiZ zaasmi has marked this topic as solved
        • zaasmiZ zaasmi

          Use …… to add table in the database
          400e9f0b-b647-4f63-9b6b-cd1c2d8011d0-image.png

          zaasmiZ Offline
          zaasmiZ Offline
          zaasmi
          Cyberian's Gold
          wrote last edited by
          #12

          said in CS310 Quiz 2 Solution and Discussion:

          Use …… to add table in the database

          To add a new table to a database, you use the CREATE TABLE statement.

          This command defines the table name and specifies the columns, including their data types (e.g., INT, VARCHAR, DATE) and any constraints (e.g., PRIMARY KEY, NOT NULL).

          Basic Syntax

          CREATE TABLE table_name (
              column1 datatype constraint,
              column2 datatype constraint,
              column3 datatype constraint
          );
          
          

          Practical Example

          If you wanted to create a table to store student information, the query would look like this:

          CREATE TABLE Students (
              StudentID int PRIMARY KEY,
              FirstName varchar(50),
              LastName varchar(50),
              EnrollmentDate date
          );
          
          

          Key Points to Remember

          • Unique Name: The table name must be unique within the database.
          • Data Types: You must define what kind of data each column will hold.
          • Primary Key: It is best practice to include a Primary Key to uniquely identify each row in your table.

          Discussion is right way to get Solution of the every assignment, Quiz and GDB.
          We are always here to discuss and Guideline, Please Don't visit Community only for Solution.
          Community Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
          [NOTE: Don't copy or replicating idea solutions.]
          VU Handouts
          Quiz Copy Solution
          Mid and Final Past Papers
          Live Chat

          1 Reply Last reply
          0
          • zaasmiZ zaasmi

            Which of the following PHP function is used to validate and sanitize the data?

            13124763-0ebd-4cd5-b247-eafeb3549a8e-image.png

            zaasmiZ Offline
            zaasmiZ Offline
            zaasmi
            Cyberian's Gold
            wrote last edited by
            #13

            said in CS310 Quiz 2 Solution and Discussion:

            Which of the following PHP function is used to validate and sanitize the data?

            The PHP function used for both validating and sanitizing data is filter_var().

            This function is highly versatile because it allows you to check if data is in the correct format (Validation) or remove illegal characters from data (Sanitization) simply by changing the “filter” flag you pass to it.

            1. Validation

            Validation checks if the data meets certain criteria. If it doesn’t, the function returns false.

            • Example: Checking if an email is valid.
            if (filter_var("test@example.com", FILTER_VALIDATE_EMAIL)) {
                echo "Valid email address.";
            }
            
            

            2. Sanitization

            Sanitization cleans the data by removing or encoding characters that could be harmful or unwanted.

            • Example: Removing HTML tags from a string.
            $clean_string = filter_var("<h1>Hello!</h1>", FILTER_SANITIZE_STRING);
            // Result: "Hello!"
            
            

            Common Filter Constants

            Filter Constant Purpose
            FILTER_VALIDATE_EMAIL Validates an email address.
            FILTER_VALIDATE_INT Validates an integer.
            FILTER_VALIDATE_URL Validates a URL.
            FILTER_SANITIZE_EMAIL Removes all characters except letters, digits and !#$%&'*±/=?^_`{|}~@.[]. |

            Why use filter_var()?

            It is much safer and more reliable than using custom Regular Expressions (Regex). Using these built-in filters helps protect your application against common security vulnerabilities like Cross-Site Scripting (XSS) and SQL Injection.

            Discussion is right way to get Solution of the every assignment, Quiz and GDB.
            We are always here to discuss and Guideline, Please Don't visit Community only for Solution.
            Community Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
            [NOTE: Don't copy or replicating idea solutions.]
            VU Handouts
            Quiz Copy Solution
            Mid and Final Past Papers
            Live Chat

            1 Reply Last reply
            0
            • zaasmiZ zaasmi

              In PHP, in order to access MySQL database you will use:
              d5906239-9553-40a9-980c-d058f7441e37-image.png

              zaasmiZ Offline
              zaasmiZ Offline
              zaasmi
              Cyberian's Gold
              wrote last edited by
              #14

              said in CS310 Quiz 2 Solution and Discussion:

              In PHP, in order to access MySQL database you will use:
              d5906239-9553-40a9-980c-d058f7441e37-image.png

              Answer: mysqli_connect() function

              In modern PHP, you have two primary, recommended ways to access a MySQL database. While older versions used the mysql_ extension, that has been deprecated and removed for security reasons.

              Today, you should use one of the following:

              1. MySQLi (MySQL Improved)

              This is a driver specifically designed for MySQL databases. It supports both procedural (using functions) and object-oriented (using classes) programming styles.

              • Best for: Projects that only use MySQL and want to take advantage of MySQL-specific features like stored procedures.
              // Object-oriented example
              $conn = new mysqli("localhost", "username", "password", "database");
              
              

              2. PDO (PHP Data Objects)

              PDO is a database abstraction layer. It provides a consistent way to interact with many different types of databases (MySQL, PostgreSQL, SQLite, etc.).

              • Best for: Flexibility. If you ever decide to switch your database from MySQL to another system, you won’t have to rewrite your entire data access code.
              // PDO example
              $dsn = "mysql:host=localhost;dbname=testdb";
              $conn = new PDO($dsn, "username", "password");
              
              

              Comparison at a Glance

              Feature MySQLi PDO
              Database Support MySQL only 12 different drivers
              Programming Style Procedural & OO Object-Oriented only
              Prepared Statements Supported (Secure) Supported (Secure)
              Named Parameters Not supported Supported

              Security Note: Regardless of which you choose, always use Prepared Statements to protect your database from SQL Injection attacks.

              Discussion is right way to get Solution of the every assignment, Quiz and GDB.
              We are always here to discuss and Guideline, Please Don't visit Community only for Solution.
              Community Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
              [NOTE: Don't copy or replicating idea solutions.]
              VU Handouts
              Quiz Copy Solution
              Mid and Final Past Papers
              Live Chat

              1 Reply Last reply
              0
              • zaasmiZ zaasmi

                Which of the following PHP syntax is used to remove all illegal characters from a URL?

                08599c0a-7636-43b5-8fd6-115cd16c6eec-image.png

                zaasmiZ Offline
                zaasmiZ Offline
                zaasmi
                Cyberian's Gold
                wrote last edited by
                #15

                said in CS310 Quiz 2 Solution and Discussion:

                Which of the following PHP syntax is used to remove all illegal characters from a URL?

                To remove all illegal characters from a URL in PHP, you use the filter_var() function combined with the FILTER_SANITIZE_URL constant.

                The Syntax

                $url = "https://example.com/search?q=hello world!";
                $clean_url = filter_var($url, FILTER_SANITIZE_URL);
                
                

                How it Works

                This specific filter is designed to clean a string by removing characters that are not permitted in a URL. It allows all letters, digits, and the following special characters:
                $-_.+!*'(),{}|\\^~[]<>#%";/?:@&=`

                Key Differences in URL Handling

                It is important to distinguish between sanitizing (cleaning) and validating (checking):

                Function Goal Filter Constant Result
                Sanitize FILTER_SANITIZE_URL Returns a “clean” string with illegal characters removed.
                Validate FILTER_VALIDATE_URL Returns the URL if it’s in a valid format, or false if it isn’t.

                Would you like me to show you how to combine both to first clean a URL and then check if the result is actually valid?

                Discussion is right way to get Solution of the every assignment, Quiz and GDB.
                We are always here to discuss and Guideline, Please Don't visit Community only for Solution.
                Community Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
                [NOTE: Don't copy or replicating idea solutions.]
                VU Handouts
                Quiz Copy Solution
                Mid and Final Past Papers
                Live Chat

                1 Reply Last reply
                0
                • zaasmiZ zaasmi

                  _______ statement is used to add a new record to a MySQL table

                  d67192ba-7d16-406f-af74-00d00b7918b8-image.png

                  zaasmiZ Offline
                  zaasmiZ Offline
                  zaasmi
                  Cyberian's Gold
                  wrote last edited by
                  #16

                  said in CS310 Quiz 2 Solution and Discussion:

                  _______ statement is used to add a new record to a MySQL table

                  The INSERT INTO statement is used to add a new record (row) to a MySQL table.

                  Basic Syntax

                  There are two primary ways to write this statement:

                  1. Specifying both column names and values:
                  This is the safest method as it ensures data goes into the correct fields.

                  INSERT INTO table_name (column1, column2, column3)
                  VALUES (value1, value2, value3);
                  
                  

                  2. Specifying values only:
                  You can omit column names if you are providing values for every column in the exact order they appear in the table.

                  INSERT INTO table_name
                  VALUES (value1, value2, value3);
                  
                  

                  Practical Example

                  If you have a table named Users, you would add a new person like this:

                  INSERT INTO Users (username, email, age)
                  VALUES ('jdoe', 'john@example.com', 25);
                  
                  

                  Key Tips

                  • Strings: Always wrap text/string values in single quotes (e.g., 'Hello').
                  • Numbers: Numeric values do not require quotes.
                  • Auto-Increment: If your table has an id column set to AUTO_INCREMENT, you don’t need to include it in your INSERT statement; MySQL will generate the number for you automatically.

                  Discussion is right way to get Solution of the every assignment, Quiz and GDB.
                  We are always here to discuss and Guideline, Please Don't visit Community only for Solution.
                  Community Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
                  [NOTE: Don't copy or replicating idea solutions.]
                  VU Handouts
                  Quiz Copy Solution
                  Mid and Final Past Papers
                  Live Chat

                  1 Reply Last reply
                  0
                  • zaasmiZ zaasmi

                    How will we retrieve the value of session variable set in the following PHP code?
                    $_SESSION[“color”] = “green”;

                    448ac04c-61a2-4da2-a13b-0de162c95fc6-image.png

                    zaasmiZ Offline
                    zaasmiZ Offline
                    zaasmi
                    Cyberian's Gold
                    wrote last edited by
                    #17

                    said in CS310 Quiz 2 Solution and Discussion:

                    How will we retrieve the value of session variable set in the following PHP code?

                    Retrieve session variable
                    Answer: (d) $_SESSION[“color”];$
                    The session variable is stored in the superglobal array $_SESSION with the key “color”. To retrieve its value, you must access this specific array using the same key. The other options use incorrect array names or incorrect keys.

                    To retrieve a session variable in PHP, you access the $_SESSION superglobal array using the specific key (name) that was used to set it.

                    The Syntax

                    If your session variable was set like this:
                    $_SESSION['username'] = "Alex";

                    You retrieve it like this:

                    echo $_SESSION['username'];
                    
                    

                    Important Steps for Retrieval

                    For the value to be accessible, you must follow these two rules:

                    1. Start the Session: You must call session_start(); at the very top of your PHP file before trying to access the $_SESSION array.
                    2. Check if it Exists: It is best practice to use isset() to avoid an “Undefined index” error in case the session has expired or wasn’t set.

                    Example Code:

                    <?php
                    session_start(); // Mandatory to access session data
                    
                    if(isset($_SESSION['username'])) {
                        echo "Welcome back, " . $_SESSION['username'];
                    } else {
                        echo "User is not logged in.";
                    }
                    ?>
                    
                    

                    Summary of Session Functions

                    Action PHP Command
                    Start/Resume session_start();
                    Set/Retrieve $_SESSION['key']
                    Remove one variable unset($_SESSION['key']);
                    Destroy all data session_destroy();

                    Would you like me to show you the specific code to set a session variable first, or perhaps how to destroy a session when a user logs out?

                    Discussion is right way to get Solution of the every assignment, Quiz and GDB.
                    We are always here to discuss and Guideline, Please Don't visit Community only for Solution.
                    Community Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
                    [NOTE: Don't copy or replicating idea solutions.]
                    VU Handouts
                    Quiz Copy Solution
                    Mid and Final Past Papers
                    Live Chat

                    1 Reply Last reply
                    0
                    • zaasmiZ zaasmi

                      Which of the following PHP syntax is used to remove all HTML tags from a string? CS310
                      6732c0fa-a97e-46bd-8cce-7a938fa8db76-image.png

                      zaasmiZ Offline
                      zaasmiZ Offline
                      zaasmi
                      Cyberian's Gold
                      wrote last edited by
                      #18

                      said in CS310 Quiz 2 Solution and Discussion:

                      Which of the following PHP syntax is used to remove all HTML tags from a string? CS310

                      To remove all HTML tags from a string in PHP, you use the filter_var() function with the FILTER_SANITIZE_STRING constant or the strip_tags() function.

                      1. Using filter_var() (Standard for sanitization)

                      This is the modern approach for cleaning input data.

                      $input = "<h1>Hello</h1> <p>World!</p>";
                      $clean = filter_var($input, FILTER_SANITIZE_STRING);
                      // Result: "Hello World!"
                      
                      

                      Note: As of PHP 8.1.0, FILTER_SANITIZE_STRING is deprecated. While still common in exam questions (like CS310), the modern replacement is htmlspecialchars() or strip_tags().

                      2. Using strip_tags() (Dedicated function)

                      This is a very common and straightforward function specifically designed to strip HTML and PHP tags from a string.

                      $input = "<b>Bold Text</b>";
                      echo strip_tags($input); 
                      // Result: "Bold Text"
                      
                      

                      Comparison of Methods

                      Method Best Use Case Key Feature
                      strip_tags() General purpose stripping Allows you to specify “allowable tags” that should NOT be removed.
                      filter_var() Data sanitization pipelines Part of a unified filtering system for emails, URLs, and integers.
                      htmlspecialchars() Security (XSS prevention) Doesn’t remove tags, but converts them to plain text so the browser won’t execute them.

                      Would you like me to show you how to use strip_tags() while keeping certain tags (like <b> or <i>) intact?

                      Discussion is right way to get Solution of the every assignment, Quiz and GDB.
                      We are always here to discuss and Guideline, Please Don't visit Community only for Solution.
                      Community Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
                      [NOTE: Don't copy or replicating idea solutions.]
                      VU Handouts
                      Quiz Copy Solution
                      Mid and Final Past Papers
                      Live Chat

                      1 Reply Last reply
                      0
                      • zaasmiZ zaasmi

                        If we want to show all the session variable values for a user session then following code will be used.

                        print_r($_SESSION);

                        12e46637-e0cf-4b8a-8e09-eb0600a3614b-image.png

                        zaasmiZ Offline
                        zaasmiZ Offline
                        zaasmi
                        Cyberian's Gold
                        wrote last edited by
                        #19

                        said in CS310 Quiz 2 Solution and Discussion:

                        If we want to show all the session variable values for a user session then following code will be used.

                        To see every variable currently stored in a user’s session, you use the print_r() or var_dump() function on the $_SESSION superglobal.

                        These functions allow you to output the entire contents of the associative array in a readable format, which is extremely helpful for debugging.

                        The Code

                        <?php
                        session_start(); // You must always start the session first
                        
                        // Option 1: Using print_r (Cleanest for reading)
                        echo "<pre>";
                        print_r($_SESSION);
                        echo "</pre>";
                        
                        // Option 2: Using var_dump (Provides more detail like data types)
                        var_dump($_SESSION);
                        ?>
                        
                        

                        Why use <pre>?

                        When using print_r() or var_dump(), wrapping the code in HTML <pre> (preformatted text) tags is a “pro-tip.” It forces the browser to display the array with proper indentation and line breaks, making it much easier for you to read than a single long line of text.

                        Common Session Commands Summary

                        Purpose Command
                        Start/Resume session_start();
                        Show All Values print_r($_SESSION);
                        Check if a variable exists isset($_SESSION['key']);
                        Clear all values session_unset();

                        Would you like me to show you how to loop through the session variables using a foreach loop if you want to format the output as a list?

                        Discussion is right way to get Solution of the every assignment, Quiz and GDB.
                        We are always here to discuss and Guideline, Please Don't visit Community only for Solution.
                        Community Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
                        [NOTE: Don't copy or replicating idea solutions.]
                        VU Handouts
                        Quiz Copy Solution
                        Mid and Final Past Papers
                        Live Chat

                        1 Reply Last reply
                        0

                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        Reputation Earning
                        How to Build a $1,000/Month PAK VS BAN Live Live Cricket Streaming
                        Ads
                        File Sharing
                        Earn with File Sharing
                        Stats

                        2

                        Online

                        3.0k

                        Users

                        2.8k

                        Topics

                        8.5k

                        Posts
                        Popular Tags
                        solution
                        1235
                        discussion
                        1195
                        fall 2019
                        813
                        assignment 1
                        428
                        assignment 2
                        294
                        spring 2020
                        265
                        gdb 1
                        238
                        assignment 3
                        79
                        Trending
                        • PM. IMRAN KHAN
                          Zaeem ChZ
                          Zaeem Ch
                          4
                          3
                          4.1k

                        • Are the vaccines halal or not?
                          undefined
                          4
                          1
                          3.9k

                        • All Subjects MidTerm and Final Term Solved Paper Links Attached Please check moaaz past papers
                          zaasmiZ
                          zaasmi
                          3
                          26
                          75.6k

                        • CS614 GDB Solution and Discussion
                          M
                          moaaz
                          3
                          3
                          8.2k

                        • How can I receive Reputation earning from Cyberian? 100% Discount on Fee
                          Y
                          ygytyh
                          3
                          28
                          24.2k
                        Online User
                        | |
                        Copyright © 2010-26 RUP Technologies LLC. USA | Contributors | Privacy | Terms
                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Pro Blog
                        • Users
                        • Groups
                        • Unsolved
                        • Solved