PHP Variables

Duration: 12 min

This video lesson is available to enrolled students.

Return to /learn/ASRB-ICAR-T3-T4-INFORMATION-TECHNOLOGY-PRELIMS-MAINS/website-development-html-javascript-css-cmsnet-jsp-php/php/basics-of-php/asset-php-variables-25295 after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Prelims: General Knowledge: Physics Chemistry Biology History Geography Polity Indian Economy Static General Knowledge GK- Current Affairs Environment
  2. Prelims: General English: Vocabulary Noun Pronoun Adjectives Preposition Articles Direct and Indirect Speech Tenses Conjunction Subject Verb Agreement (Verb Noun Agreement) Modals Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing) Sentence Correction (Error Correction) Sentence Completion (Fill in the blanks) Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions) Cloze Test (Cloze Passage) Verbal Analogy (Word Based Analogy) Sentence Construction Adverb Verb
  3. Prelims: Quantitative Aptitude: Percentage Ratio and Proportion (Ratios) HCF LCM Divisibility Rules Average Sequence and Series (Series) Number System Powers and Exponents (Surds and Indices) Algebra Profit and Loss Simple Interest and Compound Interest Time and Work Pipe and Cistern Speed Time and Distance Mixture and Alligation Mensuration and Geometry Age Problems Partnership Statistics Data Interpretation Arithmetic
  4. Prelims: General Agriculture: Agriculture in India and Tripura Natural Resource Management Fundamentals of Crop Production Horticulture Crop Improvement Crop Protection Social Science
  5. IT Mains: Operating System: Introduction to OS Process Management CPU Scheduling Process Synchronization Threads & Process Creation Deadlock Memory Management Virtual Memory Disc Scheduling File Management Distributed Systems
  6. IT Mains: Computer Networking: Introduction to CN DLL: Access Control DLL: Flow Control DLL: Error Control Data Link Layer - Ethernet Net Layer: IPv4 & Proto Net Layer: IP Addressing Net Layer:Routing Protocol Transport Layer Services TL: Congestion & UDP Application Layer Hardware Basics Network Security
  7. IT Mains: DBMS: Basics of DBMS ER Diagram Relational Model & Functional Dependencies Keys & Integrity Constraints Normalization (1NF - BCNF) Decomposition Properties & 4NF Relational Algebra SQL Relational Calculus Transaction Management Concurrency Control Database Recovery Big Data Systems Database Security & Authorization Enhanced Data Models NoSQL
  8. IT Mains: Software Engineering: Fundamentals of Software Engineering Software Requirements and Quality Assurance Software Design, Estimation and Metrics Software Testing Software Maintenance and Configuration Management
  9. IT Mains: Data Structures & Algorithms: Introduction to DS Array Stack Queue Linked List Tree Graphs Hashing Algorithm Analysis Time Complexity Analysis Sorting Algorithms
  10. IT Mains: OOPS with C++ & Java: C Fundamentals OOPS with C++ Java Fundamentals Array, String, IO & References OOPS with Java Generic & Collections Multithreading File Handling & I/O
  11. IT Mains: Python: Introduction to Python Tokens, Variables, Data Types, I/O Operators & Expressions Control Flow & Looping Collections & Strings Functions & Modules
  12. IT Mains: Website Development: Website, Browser & Services Internet Fundamentals Web Design & Development Protocols & Services Web Publishing & Hosting Server Side & Security Emerging Technologies HTML Basics HTML5 CSS JavaScript-Basics .Net Programming PHP
  13. IT Mains: Mobile App Development: Mobile Computing Multimedia
  14. IT Mains: Linux / Windows Server Admin: Unix OS Linux OS
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This lecture introduces PHP variables as data containers, covering naming rules and basic output. The instructor defines a variable as a container used to store data and presents the syntax $variable_name = value;. Key naming rules include starting with a dollar sign, beginning with a letter or underscore (not a number), allowing letters, numbers, and underscores, being case-sensitive, and not requiring an explicit data type. A C-style declaration (int x = 10) is contrasted with PHP's untyped assignment. A worked example in index.php declares $name = "Rahul"; (string), $age = 20; (integer), and $marks = 85.5; (floating-point), with browser output showing Rahul, 20, and 85.5. The lesson then moves to displaying variables with spaces using the dot (.) concatenation operator and <br> line breaks, showing echo "Name: " . $name . "<br>"; and echo "Age: " . $age;. Important points emphasize that $Name and $name are different variables, the assignment operator assigns a value, the dot joins strings in PHP, and <br> creates a line break. A second example introduces $name1 = "Ravi" and $name2 = "Sharma" to demonstrate string concatenation.

Chapters

  1. 0:00 – 2:00 00:00-02:00

    The video introduces PHP variables as containers used to store data. A slide titled 'PHP Variables' states 'A variable is a container used to store data.' and lists rules: variables start with the $ symbol, names can contain letters, numbers, and underscores. A code editor shows index.php declaring $name = "Rahul"; (string), $age = 20; (integer), and $marks = 85.5; (floating-point). The browser output displays Rahul, 20, and 85.5. The instructor points to specific lines of code and their annotations.

  2. 2:00 – 5:00 02:00-05:00

    The instructor explains naming rules, emphasizing that variable names must start with a letter or underscore and cannot begin with a number. He writes 'int x = 10' on the board to contrast C-style typed declarations with PHP's untyped syntax. On the whiteboard, he hand-writes a brace grouping 'A-Z' and 'a-z', adds '(0-9),' an X, and the example '$name = "Rahul";'. The code editor shows side notes such as 'Stores a string value' and 'Stores an integer value', plus a Syntax box reading '$variable_name = value;'. The instructor also writes an invalid variable example starting with a number.

  3. 5:00 – 10:00 05:00-10:00

    The slide header reads 'Displaying Variables with Spaces:' above a dark index.php code panel and a browser preview at http://localhost/index.php. The code shows $name = "Rahul"; and $age = 20;, with two echo lines using the dot operator: echo "Name: " . $name . "<br>"; and echo "Age: " . $age;. The browser output displays 'Name: Rahul' and 'Age: 20'. An 'Important Points' list states that $Name and $name are different variables, the assignment operator assigns a value, the dot (.) joins strings in PHP, and <br> creates a line break. The instructor points his marker at the browser output text.

  4. 10:00 – 12:16 10:00-12:16

    The instructor continues explaining how to display PHP variables with spaces using the dot operator and line breaks. He points to the code editor showing echo statements with string concatenation, then writes $name1 = "Ravi" and $name2 = "Sharma" on the whiteboard to demonstrate string concatenation with different variable names. The instructor highlights the use of the dot (.) operator to join strings and variables, reinforcing that <br> creates a line break in HTML output.

The lecture progresses from defining PHP variables to demonstrating practical usage. It begins with the core concept that a variable is a container for storing data, then systematically covers naming conventions: the mandatory $ prefix, valid starting characters (letter or underscore), allowed characters (letters, numbers, underscores), case sensitivity, and the absence of explicit type declarations. The contrast with C-style typed declarations (int x = 10) clarifies PHP's dynamic typing. The worked example with $name, $age, and $marks illustrates string, integer, and floating-point assignments. The second half focuses on output formatting using the dot concatenation operator and <br> tags, with the 'Important Points' list reinforcing key distinctions like $Name versus $name. The final example with $name1 and $name2 extends the concatenation concept to multiple variables.

Loading lesson…