Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Key Takeaways
Builds a PHP multi-dimensional array
Full Transcript
hello and welcome to the eth PHP tutorial this is going to be discussing um arithmetic operators so we're going to just start a new and let's go over real quickly the operations that we uh can do so to start we have all of the typical ones you've got um addition subtraction multiplication division uh you can also get modulus for the remainder with percentage sign and then you have Plus+ equals increment increment you know up by one and then you've got minus minus which is um basically increment down by one um um but you can also do um things like plus equals so you can say like one 1 +al 5 or something but later on I'll show you more but like let's say you had a variable um called num and that was equal to 10 you could say num plus equals 5 something like that and it just adds five to the numb variable so let's show some real examples of this so let's say let's do so add is just going to be 10 + 20 then we'll Define another one we'll call subtract equal 20 - 10 then we'll do multiply equal 10 * 20 multiple anyway uh and divide is going to equal 20 ID 10 okay uh and then let's say we want let's go ahead and Echo out that stuff real quick so Echo add and then we're just going to append uh breaks to all of these so we can see uh the difference break break and I'm just going to copy and paste this ending break so we can do this really quick um actually let's do the whole line and I'll just change ah we didn't add the quotes though all right here we go subtract multiple multiple and divide so now we'll save this and we'll put it up on the server over here run parse error line three we did not add a oh gosh we didn't do it on any of these manang there we go so now you've done all the math 30 10 200 to let's make sure yep 10 + 20 is 30 20 - 10 is 10 200 that's good and then obviously two great so what else can we do well another thing that you can do is some math so let's say we want to do 30 and we'll do times 10 so we can take these variables because you don't have to just use numbers you could do it with variables so let's do um Echo add times um multiple save and we'll throw this up and now you can see we echoed out 30 * 200 = 6,000 now of course we can do the same thing we can you know divide here put that over and you see we have decimal there of5 and so on so of course you can do this with variables as well now the last thing I'm going to really show you is kind of aritic rules for example so what we're going to do is Echo um we'll just do 5 + 3 / 15 so in your head you might be thinking that's going to be 8 / 15 um but what's going to happen due to rules of mathematics is it's actually going to be 5 + 3 / 15 so if you wanted to break it down easier that's what's going to be output so let's go ahead and show you that save it put that up on the server run and as you can see yes it is indeed it's 5.2 so what do we do about that well if you haven't already figured out when I showed you the parentheses you of course are going to put this so now it's going to be 8 / 15 and we'll save that pop over here refresh and now you've got a much more the answer that you really looking for if that was the case because you might have been looking for 5 + 3 ID 15 um but anyway you can just use these parentheses no different than you would with a calculator to arrive at the proper answer so finally let's discuss uh the incrementals so we'll say number decrease equals 10 and then number decrease um let's do actually let's use what we've already used so we'll say add Plus+ so you're just adding to what exists now we want to Echo out um add so initially add was equal to 10 + 20 so 30 and we print out 30 here and now let's see what happens when we call um the Plus plus plus as you can see it outputs a 31 now what if we change this to a minus minus we'll save that come over here refresh and as you can see it minus one from it now there's a couple other things that you can do you can do the plus equals like I was saying so let's say plus equals 50 so now it's going to do 30 + 50 and we'll come over here refresh and as you can see it gave us an 80 and then finally you can do minus equals 500 let's say come back over here refresh and now you've got a470 so anyways those are all the um arithmetic operators how to use them um in time you'll probably use the incremental one um and then also basic math is pretty much integral to a lot of programming so um as always thanks for watching thanks for your support your subscription and until next time
Original Description
Link to the full playlist:
http://www.youtube.com/playlist?list=PLQVvvaa0QuDcYpcjrNB43_iKqla5UeQw_
Sentdex.com
Facebook.com/sentdex
Twitter.com/sentdex
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from sentdex · sentdex · 28 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
▶
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
Python Encryption Tutorial with PyCrypto
sentdex
Python's Logging Function
sentdex
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
wxPython Programming Tutorial 4: Panels
sentdex
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
wxPython Programming Tutorial 8: Custom Button Images
sentdex
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
Basic PHP Tutorial 12: Associative Array
sentdex
Basic PHP Tutorial 14: Foreach loop
sentdex
Basic PHP Tutorial 16: Include and Require
sentdex
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
Basic PHP Tutorial 4: Variables and Comments
sentdex
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
Basic PHP Tutorial 1: Intro to PHP
sentdex
Basic PHP Tutorial 3: HTML with PHP
sentdex
Basic PHP Tutorial 9: While Loop
sentdex
Basic PHP Tutorial 10: Switch Statement
sentdex
Basic PHP Tutorial 2: Print and Echo
sentdex
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
Basic PHP Tutorial 19: Finding words in strings
sentdex
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
Basic PHP Programming Tutorial 24: String similarity
sentdex
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
Sikuli Tutorial 1: Visually programming in python!
sentdex
Sikuli Tutorial 2: Program visually in python!
sentdex
Sikuli Tutorial 3: Program visually in python!
sentdex
3D Bar Charts in Python and Matplotlib
sentdex
3D Plane wire frame Graph Chart in Python
sentdex
Raspberry Pi Part 1 Introduction
sentdex
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
Raspberry Pi Part 11: Remote Desktop
sentdex
Twitter Analysis: How to rank a user's influence
sentdex
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex
Related Reads
📰
📰
📰
📰
I Built a Free AI-Powered YouTube SEO Toolkit With Zero Budget. Here’s What Actually Happened.
Medium · Startup
How to Create a Second Version of Yourself Inside Obsidian Using AI (Step-by-Step Guide)
Medium · ChatGPT
How to prepare for Spain civil service TIC exam using AI in 2026
Dev.to · David García
Going Viral! How I Created AI Kissing Videos Step by Step Easily Using AIAI.com
Medium · AI
🎓
Tutor Explanation
DeepCamp AI