CS Knowledge Opener - Logo
CS Knowledge
Opener
Facebook Youtube Telegram
  • Home
  • 12th CS
    • 12th CS English Medium
    • 12th CS Tamil Medium
  • 12th CA
    • 12th CA English Medium
    • 12th CA Tamil Medium
  • 11th CS
    • 11th CS English Medium
    • 11th CS Tamil Medium
  • 11th CA
    • 11th CA English Medium
    • 11th CA Tamil Medium
  • CS / CA Question Bank
  • Other Subjects
  • Student Alerts
  • Govt Exams
  • Home
  • 12th CS
    • 12th CS English Medium
    • 12th CS Tamil Medium
  • 12th CA
    • 12th CA English Medium
    • 12th CA Tamil Medium
  • 11th CS
    • 11th CS English Medium
    • 11th CS Tamil Medium
  • 11th CA
    • 11th CA English Medium
    • 11th CA Tamil Medium
  • CS / CA Question Bank
  • Other Subjects
  • Student Alerts
  • Govt Exams
CS Knowledge Opener - Logo
CS Knowledge
Opener
Facebook Youtube Telegram
  • Home
  • 12th CS
    • 12th CS English Medium
    • 12th CS Tamil Medium
  • 12th CA
    • 12th CA English Medium
    • 12th CA Tamil Medium
  • 11th CS
    • 11th CS English Medium
    • 11th CS Tamil Medium
  • 11th CA
    • 11th CA English Medium
    • 11th CA Tamil Medium
  • CS / CA Question Bank
  • Other Subjects
  • Student Alerts
  • Govt Exams
  • Home
  • 12th CS
    • 12th CS English Medium
    • 12th CS Tamil Medium
  • 12th CA
    • 12th CA English Medium
    • 12th CA Tamil Medium
  • 11th CS
    • 11th CS English Medium
    • 11th CS Tamil Medium
  • 11th CA
    • 11th CA English Medium
    • 11th CA Tamil Medium
  • CS / CA Question Bank
  • Other Subjects
  • Student Alerts
  • Govt Exams
12th CA English Medium

Practical program exercise 7 PHP Create & Execute Variables for 12th computer applications

Baskaran J
February 15, 2023 3 Mins Read
1K Views
0 Comments

7 .PHP Create & Execute Variables

Variable in PHP

  • PHP has variables like other programing languages such as C, C++ and Python etc.
  • Variables are the storage location, which can store the values for the later manipulations in the program.
  • The variable in PHP begins with a dollar ($) symbol and the assignment activity implemented using “=” operator, finally the statement ends with semi colon “;”
  • The semicolon indicates the end of statement.
  • The main advantage of the PHP variable declaration is, it does not requires to specify the data type keyword separately such as int, char, float, double or string etc.

Operators in PHP

  • Operator is a symbol which is used to perform mathematical and logical operations in the programing languages.

Arithmetic operators

  • The arithmetic operators in PHP perform general arithmetical operations, such as addition, subtraction, multiplication and division etc.

Assignment Operators

  • Assignment operators are performed with numeric values to store a value to a variable.
  • The default assignment operator is “=”. This operator sets the left side operant value of expression to right side variable

Increment and Decrement Operators

  • Increment and decrement operators are used to perform the task of increasing or decreasing variable’s value.
  • This operator is mostly used during iterations in the program logics.

PHP Function

  • PHP server side scripting language Functions and array concepts are very important to solve the many complex problems in real world.
  • In most of the programming language, a block of segment in a program that perform specific operations like (Insert, Execute, Delete, Calculate, etc.).
  • This are known as Functions.
  • A Function is a type of sub routine or procedure in a program.
  • A Function will be executed by a call to the Function and the Function returns any data type values or NULL value to called Function in the part of respective program.

Pre-defined or system or built in function

  • PHP has a wide collection of built-in functions  that can be called directly from with in a script, to perform a specific task.
  • These built in function are what make PHP a very efficient and productive. Scripting language no installation is required to use these functions.

CA – 7 PHP – CREATE & EXECUTE VARIABLES

QUESTION:

Write a PHP code to demonstrate the usage of global and static variables in PHP.

AIM:

To create and execute a PHP Variables Example program

PROCEDURE:

  1. Start Xampp server (Apache)
  2. Go to virtual path folder (C:\xampp\htdocs)
  3. Create test.php file and type the program
  4. Execute the program on your Web browser using by this URL link (http://localhost/test.php)

PROGRAM:

<html>

<body>

<?php

$a = 25;

$b = “Hello”;

$c = 5.7;

echo “Number is : “.$a.”<br>”;

echo “String is : “.$b.”<br>”;

echo “Float value : “.$c.”<br>”;

$txt = “INDIA! <br>”;

echo “I love $txt”;

$x = 2;

$y = 2;

echo $x + $y;

function demo()

{

echo “<p>Variable x inside function is:$x</p>”;

}

demo();

echo “<p>Variable x outside function is: $x</p>”;

function myTest()

{

static $a = 0;

echo $a;

$a++;

}

myTest();

echo “<br>”;

myTest();

echo “<br>”;

myTest();

echo “<br>”;

?>

</body>

<html>

OUTPUT:

Number is : 25
String is : Hello
Float value : 5.7
I love INDIA!
4
Notice: Undefined variable: x in C:\xampp\htdocs\var.php on line 17

Variable x inside function is:

Variable x outside function is: 2

0
1
2

RESULT:

The Output was verified successfully

 

 

Tags:

Practical

Share Article

Follow Me Written By

Baskaran J

Other Articles

Previous

Practical program exercise 6 PHP Basic Programing for 12th computer applications

Next

Practical program exercise 8 PHP Create & Execute Echo and Print Statements for 12th computer applications

Next
February 16, 2023

Practical program exercise 8 PHP Create & Execute Echo and Print Statements for 12th computer applications

Previous
February 13, 2023

Practical program exercise 6 PHP Basic Programing for 12th computer applications

No Comment! Be the first one.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

12 − 5 =

Related Posts

12th CA Board Exam Answer Key Discussion 2024-2025

Baskaran J
March 14, 2025

12th Computer Applications English medium Program Question 2024-2025

Baskaran J
February 23, 2025

12th Computer Applications Practice One marks question 2024-2025

Baskaran J
February 3, 2025

12th Computer Applications English medium Public Exam Important Question 2024-2025

Baskaran J
January 16, 2025

Subscribe to our newsletter and stay updated.

CS Knowledge Opener

CS Knowledge Opener focuses on 11th &12th Computer Science & Computer Applications English Medium & Tamil Medium. Programming Skills and also we are Publishing Study Materials Based on New syllabus introduced by TNSCERT. (TNBOARD).

Quick Links

  • Contact Us
  • About Us
  • Privacy Policy
  • Disclaimer
  • Terms and Conditions
Categories
11th CA English Medium 15
11th CA Tamil Medium 9
11th CS English Medium 21
11th CS Tamil Medium 12
12th CA English Medium 32
12th CA Tamil Medium 8
12th CS English Medium 36
12th CS Tamil Medium 12
Government Exams 36
Notifications 8
Other Subjects 13

Follow Us

Youtube
Facebook
Telegram
CS Knowledge Opener © 2020 - 2025. All Rights Reserved.