PHP-language Variables, assingment and arithmetic operations Teppo Räisänen Principal Lecturer...
-
Upload
horatio-barton -
Category
Documents
-
view
216 -
download
3
Transcript of PHP-language Variables, assingment and arithmetic operations Teppo Räisänen Principal Lecturer...
![Page 1: PHP-language Variables, assingment and arithmetic operations Teppo Räisänen Principal Lecturer Oulu University of Applied Sciences School of Business and.](https://reader036.fdocuments.net/reader036/viewer/2022083009/5697c01c1a28abf838ccff5b/html5/thumbnails/1.jpg)
PHP-languageVariables, assingment and arithmetic
operations
Teppo RäisänenPrincipal Lecturer
Oulu University of Applied SciencesSchool of Business and Information Management
[email protected], 050 382 6587
![Page 2: PHP-language Variables, assingment and arithmetic operations Teppo Räisänen Principal Lecturer Oulu University of Applied Sciences School of Business and.](https://reader036.fdocuments.net/reader036/viewer/2022083009/5697c01c1a28abf838ccff5b/html5/thumbnails/2.jpg)
Variables
• Data prosessed by (web) application is stored into variables
• PHP-application is executed on web server -> variables are in the memory of the web server
• When you declare a variable, you don’t give datatype (but still variables do have datatype) -> PHP is so called loosely-typed programming language
• Basic datatypes: boolean, integer, floating point number and string
![Page 3: PHP-language Variables, assingment and arithmetic operations Teppo Räisänen Principal Lecturer Oulu University of Applied Sciences School of Business and.](https://reader036.fdocuments.net/reader036/viewer/2022083009/5697c01c1a28abf838ccff5b/html5/thumbnails/3.jpg)
Declaring variables
• Variable declaring starts with $-character• You invent the name for the variable• Good practise is to give initial value• Example:
$age=0;$firstname=””;$isTrue=false;
![Page 4: PHP-language Variables, assingment and arithmetic operations Teppo Räisänen Principal Lecturer Oulu University of Applied Sciences School of Business and.](https://reader036.fdocuments.net/reader036/viewer/2022083009/5697c01c1a28abf838ccff5b/html5/thumbnails/4.jpg)
Assignment (= operator)
• Assingment is used to store data into variable– User input– Result of an clause
• Examples.$age=24;$name=$_POST[”firstname”];$total=$number1 + $number2;$fullname=$firstname . $surname;
![Page 5: PHP-language Variables, assingment and arithmetic operations Teppo Räisänen Principal Lecturer Oulu University of Applied Sciences School of Business and.](https://reader036.fdocuments.net/reader036/viewer/2022083009/5697c01c1a28abf838ccff5b/html5/thumbnails/5.jpg)
Arithmetic operations
• + addition• - subtraction• / division• * multiplication• % remainder
![Page 6: PHP-language Variables, assingment and arithmetic operations Teppo Räisänen Principal Lecturer Oulu University of Applied Sciences School of Business and.](https://reader036.fdocuments.net/reader036/viewer/2022083009/5697c01c1a28abf838ccff5b/html5/thumbnails/6.jpg)
Printing information with PHP
• echo, print ja printf
![Page 7: PHP-language Variables, assingment and arithmetic operations Teppo Räisänen Principal Lecturer Oulu University of Applied Sciences School of Business and.](https://reader036.fdocuments.net/reader036/viewer/2022083009/5697c01c1a28abf838ccff5b/html5/thumbnails/7.jpg)
Reading values from HTML-form using HTTP-post method