9 | PHP Exercise for Beginners: Create a Calculator! | 2023 | Learn PHP Full Course for Beginners

  Рет қаралды 55,222

Dani Krossing

Dani Krossing

Күн бұрын

Пікірлер: 102
@amirgohary
@amirgohary Жыл бұрын
Is it wrong to use htmlspecialchars with input numbers instead of filter_input ?
@Dani_Krossing
@Dani_Krossing Жыл бұрын
No it is not. 🙂 However it is important to know the difference between them, since they serve different purposes. I'll briefly explain them bellow. 😊 For the sake of my explanation, let's pretend I somehow managed to type
@amirgohary
@amirgohary Жыл бұрын
@@Dani_Krossing Thanks for replying Do you have courses at Udemy, I tried to reach you but did not find. I would suggest if you create multi tenant for core php, "not laravel" It will be very helpful for most people because there is no available course for multi tenant core php
@Dani_Krossing
@Dani_Krossing Жыл бұрын
@@amirgohary Everything I create is freely available on KZbin. 🙂 One of my main goals when I started this channel, was to make sure that people who couldn't afford college, had a place to learn.
@yousifky
@yousifky Жыл бұрын
​@@Dani_Krossing that's why you are the best teacher on KZbin ❤
@tarkmenguc8031
@tarkmenguc8031 Жыл бұрын
Thank you for this explanation! It helped a lot!@@Dani_Krossing
@FirdavsiGameDev
@FirdavsiGameDev 9 ай бұрын
I'm new to PHP and building this calculator brought so much joy to learning. I wish you had more of these mini projects within your courses.
@EverydayJason
@EverydayJason Жыл бұрын
whoa thought you were done with PHP. Glad to see you are still building tutorials for it. I am a full time PHP developer now and I started learning to code from videos of yours from ages ago. Well before ChatGPT, tuts like yours were one of the best ways to learn. I still use your file upload script that I built from watching your tutorial back a million years ago
@Commenter339
@Commenter339 9 ай бұрын
Thanks, Dani! Your videos are great. They make learning so much easier, because I watch not just because "I have to learn", but because they're fun to watch and easy to understand. And that's quite an achievment, if you ask me!
@saidadan9982
@saidadan9982 2 ай бұрын
I would like to take this opportunity to thank you for the great work you are doing, you explain everything in details until everyone understands. In university lectures don’t even teach the way you are,simplifying all the complex concepts. You have given me hope to continue learning programming. Stay blessed 🙏
@constantine9074
@constantine9074 Жыл бұрын
Im planning to learn php soon.. i know which channel im gonna watch 😊 thank you for your time
@rkendtoend
@rkendtoend Жыл бұрын
Back to basics 😍. Really enjoy yours videos. Thanks a lot.
@mahnooraltaf8525
@mahnooraltaf8525 Жыл бұрын
I liked your way of teaching. Please continue with it.If you have read my comment, then reply.
@AgenceWebSigma
@AgenceWebSigma 9 ай бұрын
Good tutorial as usual from a nice teacher!
@lawrencemichael5571
@lawrencemichael5571 28 күн бұрын
Dani Krossing is the man! Been a fan since MMTUTS days!
@falkOnAir
@falkOnAir 4 ай бұрын
Dear Dani, it is a pleasure to watch your tutorials. Thanks for your work! You are wondering why it is possible to type in some letters in the numb-input-field and the reason for that is: "The number e (Euler's number) is a mathematical constant approximately equal to 2.71828 that can be characterized in many ways."(src="wiki")
@The-Ma5ter
@The-Ma5ter 11 ай бұрын
Thank you so much sir, you are an amazing teacher best of the best
@sleepysapphire2349
@sleepysapphire2349 Жыл бұрын
Learning PHP for the server side just feels right, especially with your way of explaining things. I've been scratching my head trying to learn Flask(python). It feels weird especially because of OOP.
@ramen_012
@ramen_012 Жыл бұрын
18:47 thanks for the tip
@michaelsunday6860
@michaelsunday6860 2 ай бұрын
You are a Genius!!!
@mayureshchavan3382
@mayureshchavan3382 Жыл бұрын
Keep it up bro UR doing Awesome Work 👍
@lahcenaouina
@lahcenaouina Жыл бұрын
THANKKKKK YOU
@alexsaptetrei
@alexsaptetrei Жыл бұрын
In case of divide, i would also check the value of num2. Division by 0 is an illegal operation.
@sonamohialdin3376
@sonamohialdin3376 Жыл бұрын
This is very useful tutorial thank you
@nancyosumba5350
@nancyosumba5350 10 ай бұрын
Hi Daniel, your videos have been very useful for a beginner like me. Wanted to ask if you can create a video showing how to create a to do list with php. it should have this functions PHP, HTML, and CSS with a connection to an SQL database containing a table for tasks (Bootstrap/Tailwind/Sass or other can be used for styling). Each task should have: A unique ID A title A task description Completion status (whether the task is done) The user should be able to: View all tasks Add a task Edit a task Delete a task Mark a task as completed. Enable the creation of different users on the page and have multiple task lists associated with a specific user, editable only by that user and not visible to other users. Implement functionality to remove all completed tasks. Implement functionality to mark all tasks as completed. Allow users to register and log in to the page, and provide the capability to change their username and other settings such as the page's color theme or other similar preferences. once again thank you for your work much appriciated.
@AleJFF25
@AleJFF25 Жыл бұрын
The letter "e" at 21:52, is it not the Euler's constant? Maybe HTML considers it at a number. Or more likely to be like 1e10 for example, to the power of 10.
@Sweetcommando
@Sweetcommando 7 ай бұрын
Yeah I think he just managed to type in the one letter by chance that can be inputted in there lol
@nenadkardum639
@nenadkardum639 10 ай бұрын
Hello Dani!! Thank you for your videos and all your efforts, you are an awesome person and great teacher! 💪💪💪 I have problem when trying to do some math in "our" calculator. The message I get is this one: Fatal error: Uncaught Error: Undefined constant "num02" in C:\xampp\htdocs\test.php:44 Stack trace: #0 {main} thrown in C:\xampp\htdocs\test.php on line 44 This is part of code if (!is_numeric($num01) || !is_numeric(num02)){ echo "Only write numbers!"; $errors = true; } is causing error..when I delete it then it all works fine. I will put my whole work in next comment so if you have time please take a look at it.
@deitunegold4593
@deitunegold4593 Жыл бұрын
Hello dani, I’m trying to learn how to create a chat system in php. I feel like learning that would take me to another level. Can you do tutorial on that please ?☺️
@GerritforBazeja
@GerritforBazeja Жыл бұрын
It's nice so much time you take to explaine why en what you're doing
@mortwain1809
@mortwain1809 Жыл бұрын
It was a very nice video, thank you. Could you make a video with a few examples to show the differences between htmlspecialchars() and filter_input()?
@Dani_Krossing
@Dani_Krossing Жыл бұрын
htmlspecialchars() simply converts any special characters into HTML entities. So for example "&" would become "&", which makes it "non-dangerous". Where as filter_input() actually sanitize the data, by returning false if the input was invalid. It's important to mention here though, that php.net recommends always using htmlspecialchars() for string data. 🙂 But if you are dealing with other types of data, then you can use either function, depending on what you are trying to do.
@mortwain1809
@mortwain1809 Жыл бұрын
@@Dani_Krossing thnx for explanation
@guillerjamesmantala7311
@guillerjamesmantala7311 2 ай бұрын
thankyou sir
@jujomoto
@jujomoto Жыл бұрын
great tuto, thanks for sharing 😃
@jahidsafiullah7270
@jahidsafiullah7270 4 ай бұрын
Love from Bangladesh
@drlawrencemayo
@drlawrencemayo 2 ай бұрын
Hi danni im a doctor in medical field, can we do a medical oriented project on you channel. such as patient database using php?
@WillemsWimMH
@WillemsWimMH 8 ай бұрын
About double or single quotes around 28:15 I did notice that in my code when I don't use quotes to define the class in html it works fine too (in something I created myself). I wrote the following:
@Dani_Krossing
@Dani_Krossing 8 ай бұрын
You should always follow the regular HTML rules, even when putting it inside PHP. 🙂 There could very well be a specific reason why in your case it works, but maybe not when others test it on their devices or browsers.
@nihongo_
@nihongo_ Жыл бұрын
Thank you bro
@AxxionMarketPlace-iu6ri
@AxxionMarketPlace-iu6ri Жыл бұрын
Thank you
@Couldbeme
@Couldbeme Жыл бұрын
Woah that’s cool!
@achmaliki8389
@achmaliki8389 Жыл бұрын
i used match over switch, is there better use switch rather than match ?
@zorenromera
@zorenromera Жыл бұрын
in the select option if I select multiplication or any other operation after submitted, the select option back to addition it's kind a (default), how can I possibly stick with the chosen operation even if I submit the form? I am hoping to your answer teacher Dani :D
@harshwebdeveloper
@harshwebdeveloper Жыл бұрын
really it's helpful video
@vedantpillai353
@vedantpillai353 8 ай бұрын
Hello, I have just started learning php. At 22:48 the is_numeric function also seems to check whether the given variable is empty or not. So, if we use only that if block and remove the if block from 20:38, would it give me some kind of error?
@Stoney_Eagle
@Stoney_Eagle Жыл бұрын
Hehe really hammering down on the security, almost sounds like you enjoy it 😂
@Dani_Krossing
@Dani_Krossing Жыл бұрын
haha well when people keep telling me to use "HTML as security", I do find it satisfying to prove those comments wrong in a video 😂 Or at least from knowing that this video won't get those comments.
@valentinbonchev7485
@valentinbonchev7485 12 күн бұрын
Hello! 21:45 : Why do we need the boolean $errors? Cant we just do the if structure to check if the fields are empty without the boolean and has the same effect?
@valentinbonchev7485
@valentinbonchev7485 12 күн бұрын
Nevermind! I understood that the Calculation part of the code wont run, sorry!
@jeanwill69
@jeanwill69 7 ай бұрын
Just wondering why using float when you can't entering float number when using type="number" in html ? Thanks, JF
@yomammo
@yomammo 7 күн бұрын
could you keep your error handling code separated from the main code? in its own php file.
@User97356
@User97356 Жыл бұрын
THANK YOU.. can you make a payment system
@DigitaleDemocratie714
@DigitaleDemocratie714 Жыл бұрын
Hello, i créated the calculator but i have a problem. The file works om my brothers Mac but not on my win10. The echo’s do not work on my pc. I don’t see the result and the other echo massages. I use the latest versión of xampp . It’s not a mistake in the script because it works on my brothers system. Other echo’s outside of the calculator do work. What could be be the problem?
@PicnicGamingX
@PicnicGamingX Жыл бұрын
would it not be better if we use AND instead of OR while checking if the number is not numeric
@Dani_Krossing
@Dani_Krossing Жыл бұрын
No because if you put a AND instead, then both have to not be numbers before it counts as an error. 🙂 If you put a OR then only one of them has to not be a number.
@PicnicGamingX
@PicnicGamingX Жыл бұрын
@@Dani_Krossing Thank you so much for removing my confusion. Your tutorials are really helpful. I have a request for you to make tutorials of Laravel also because, i started internship as Laravel developer and i find laravel really hard to use. Out of all the internet i find only your tutorials helpful so please make Laravel tutorial series.
@adobeadobe1616
@adobeadobe1616 5 ай бұрын
I'm having a problem with create html canvas elements with php.. Things that work in html canvas with an html file work, but when i use da canvas element and select it in a js file with php it doens't show..
@lucaslannes4004
@lucaslannes4004 Жыл бұрын
Hello from Brazil! Why did you use "echo" before htmlspecialchars, after all echo is not to just show something on screen? I tried without it and worked the same. I mean, is there a purpose or does the same? . Its my second day learning PHP, be patient😅
@Dani_Krossing
@Dani_Krossing Жыл бұрын
Echo is used to show content on screen, and htmlspecialchars is used to prevent the outputted content to be malicious 🙂 so our website doesn’t get attacked using XSS.
@abubakarrishi5332
@abubakarrishi5332 Жыл бұрын
Ahh thanks also I want social website in php please project making
@zeuz3961
@zeuz3961 11 ай бұрын
22:22 "e" is actually a number :D just like "i" but it is not imaginary :P
@fotonext7441
@fotonext7441 Жыл бұрын
Can I use FILTER_VALIDATE_FLOAT instead of FILTER_SANITIZE_NUMBER_FLOAT? Is the same thing? Or are there differences?
@heinzerbrew
@heinzerbrew 9 ай бұрын
one santitzes the other validates
@AndiBradley
@AndiBradley 6 ай бұрын
I tried to do a calculation 100 / 0.5 and it gave me an error. Is that my browser causing that or something else? Anything with a decimal point causes an error. Maybe the age of my PHP software?
@RespectEveryoneForever
@RespectEveryoneForever 8 ай бұрын
bro how u arranged it fast on 25:51, u alligned it very quick
@rogerrives7096
@rogerrives7096 Ай бұрын
I found out why it was not working with floats. In the form when we set the
@rogerrives7096
@rogerrives7096 Ай бұрын
I love the course by the way
@rogerrives7096
@rogerrives7096 Ай бұрын
and like @TheSocks221 pointed out you also need to include " $num1 = filter_input(INPUT_POST, "num1",FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); $num2 = filter_input(INPUT_POST, "num2",FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);"
@EL_WAFI_CHERKAOUI
@EL_WAFI_CHERKAOUI 7 ай бұрын
i have quetions , why you wrote echo inside action attr in form , why do we need to echo the data ? isnt action attr work is to send data to server ? why echo then ?
@heinzerbrew
@heinzerbrew 9 ай бұрын
Sanitizing numbers instead of just veirfying that they are numbers seems like a bad idea. How can you trust that the sanitized data was the intended input?
@marlo4108
@marlo4108 Жыл бұрын
but it does not accept float numbers
@heinzerbrew
@heinzerbrew 9 ай бұрын
I am confused why do you say PHP_SELF can be altered by a malicious user? (starting around 4 minute mark) Edit: it seems that it isn't actually the file itself that is referenced, but instead the url in the browser including any random extra stuff that a person types into the url...
@danieligbinidu6880
@danieligbinidu6880 Жыл бұрын
💯💯💯💯
@tendounosaiba8366
@tendounosaiba8366 10 ай бұрын
How can you autocomplete HTML in PHP sir?
@GoldDiscover333
@GoldDiscover333 Жыл бұрын
Sir some people says that php shall be end! He is really kindly cover this topic in specific video
@Dani_Krossing
@Dani_Krossing Жыл бұрын
My first video in this series, talks about that specific issue. 😊 Spoiler alert, "PHP is not dying" hehe
@go_all_the_way
@go_all_the_way 7 ай бұрын
Can't access the project files. It seems like there is text in the description that is intended to be a hyperlink but instead is just plain text. Anyone else having this issue?
@Dani_Krossing
@Dani_Krossing 7 ай бұрын
The "➤ GET ACCESS TO MY LESSON MATERIAL HERE!" is just the header. The links are bellow. 🙂
@namataymichael5841
@namataymichael5841 7 ай бұрын
Echo out for Result is not showing text .. maybe something went wrong
@chytoms
@chytoms 7 ай бұрын
Check on your stylesheet! Had same problem but after unlinking my stylesheet everything is fine unless your code got a problem in which case you can turn on display_errors in your php.ini file to see the exact line with the error
@jggh88hvhj
@jggh88hvhj Ай бұрын
I couldn't get why we used POST and not GET??
@godstimesamuel3633
@godstimesamuel3633 3 ай бұрын
Hi sir, I tried this out on my laptop but it ain’t working 😌
@constantine9074
@constantine9074 Жыл бұрын
link is not working :(
@HubertAgbozo
@HubertAgbozo Жыл бұрын
I got an error : Fatal error: Uncaught TypeError: filter_input(): Argument #3 ($filter) must be of type int, string given in C:\xampp\htdocs\PHP calculator\index.php:39 Stack trace: #0 C:\xampp\htdocs\PHP calculator\index.php(39): filter_input(0, 'operator', 'add') #1 {main} thrown in C:\xampp\htdocs\PHP calculator\index.php on line 39
@Dani_Krossing
@Dani_Krossing Жыл бұрын
It means you accidentally set the operator to check for an integer, when you use the filter check.
@ulhassananwar
@ulhassananwar 7 күн бұрын
where are yours css files
@Dani_Krossing
@Dani_Krossing 7 күн бұрын
At the bottom of my description
@chanmyaemaung
@chanmyaemaung Жыл бұрын
You look quite similar to Elon Musk, so I had to ask whether the two of you are related. 🤭
@princessteranacaramrasonablehe
@princessteranacaramrasonablehe 7 ай бұрын
😂 I though it was only me who noticed
@vipuljasrotia7518
@vipuljasrotia7518 12 күн бұрын
You look like Elon Musk ..😁
@tanzimwalweni6569
@tanzimwalweni6569 11 ай бұрын
Whenever you show any type of text thats html / css (not php) I lose track of the information im learning and things stop making sense. It would be easier if you JUST did php only.
@Dani_Krossing
@Dani_Krossing 11 ай бұрын
Most PHP is done in coorporation with HTML, so it's important to learn how to use them together. 🙂 You should be very familiar with HTML already, if you started learning PHP. So if you struggle with the HTML part, then I recommend catching up on it, so it's easier to follow along.
@heinzerbrew
@heinzerbrew 9 ай бұрын
I'm guessing you are mememing, because he has said so many times that people don't like him showing non-php code.
@raphaelevangelio2897
@raphaelevangelio2897 3 ай бұрын
its irritating me that youre teaching very fast and didnt even explain how you did that echo of the error handlers. Now im still confused.
@sonamohialdin3376
@sonamohialdin3376 Жыл бұрын
This is very useful tutorial thank you
How to create a simple arithmetic calculator using laravel
40:36
Jubair Ahmed Junjun
Рет қаралды 6 М.
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 4,7 МЛН
Turn Off the Vacum And Sit Back and Laugh 🤣
00:34
SKITSFUL
Рет қаралды 7 МЛН
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 18 МЛН
Smart Sigma Kid #funny #sigma
00:33
CRAZY GREAPA
Рет қаралды 14 МЛН
NVIDIA’s New AI: Stunning Voice Generator!
6:21
Two Minute Papers
Рет қаралды 95 М.
Build this JS calculator in 15 minutes! 🖩
15:20
Bro Code
Рет қаралды 668 М.
How To Make A Calculator Using HTML CSS And JavaScript
19:01
GreatStack
Рет қаралды 933 М.
PHP For Beginners | 3+ Hour Crash Course
3:15:36
Traversy Media
Рет қаралды 798 М.
Are we going back to PHP with fullstack JavaScript?
9:57
Maximilian Schwarzmüller
Рет қаралды 154 М.
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 4,7 МЛН