Exercise Using PHP | Let’s Build a Calculator | PHP Tutorial | Learn PHP Programming. In this PHP lesson you will do a short exercise where we use some of the knowledge we have gathered from previous episodes. The primary reason behind this exercise, is to show how we can use what we have learned so far, to build an actual PHP application on our website.
➤ GET ACCESS TO MY LESSON MATERIAL HERE!
First of all, thank you for all the support you have given me!
I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!
I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.
I hope you will find it helpful 🙂
Material for this lesson:
Nguồn:https://wijstaanvooronzegrondrechten.org/
U havent explain GET or isset() yet and u r using it but thats not a big deal but i think u should have explain that in this start of this series
You're a good teacher, man. Thank you!
When I hit calculate, nothing happens in the url. Yes my file is saved as a php file and there are no errors popping up. What can the issue be?
Woo-hoooot!! I just became a 5$/month patreon! 🙂
First time ever I do this but this account's content is worth it.
You are fantastic! I love your tutorials, thank you so very much. These are well presented, organised, easy to follow/understand. Thank you, thank you, thank you!!!!
hey do you like gyros?
In my case, only the Add option works. The rest of the 3 options don’t work
Notice: Undefined index: operator in D:serverhtdocsAndylandindex.php on line 28
WHY!!!!!
Thnk u
i am sure the code is correct ? but dosn't work? help plz
🙁
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form>
<input type="text" name="num1" placeholder="write the number1.."><br>
<select name="operator">
<option>None</option>
<option>+</option>
<option>-</option>
<option>*</option>
<option>/</option>
</select><br>
<input type="text" name="num2" placeholder="write the number2.."><br>
<button type="submit" value="submit" name="sumbit">Calculate</button>
</form>
<p>Inatija hiya:</p>
<?php
if (isset($_GET['submit'])){
$result1 = $_GET['num1'];
$result2 = $_GET['num2'];
$op = $_GET['operator'];
switch ($operator){
case "None":
echo "you need to select a method";
break;
case "+":
echo $result1+$result2;
break;
case "-":
echo $result1-$result2;
break;
case "*":
echo $result1*$result2;
break;
case "/":
echo $result1/$result2;
break;
}
}
?>
</body>
</html>
You're the best man, thank you.
i dont get to see my answer
Dude you're great!
I got two errors:
"Warning: Use of undefined constant None – assumed 'None' (this will throw an Error in a future version of PHP) in C:xampphtdocsphplessonsindex.php on line 33
Warning: Use of undefined constant Add – assumed 'Add' (this will throw an Error in a future version of PHP) in C:xampphtdocsphplessonsindex.php on line 36
Do you know why these are popping up?
I attached code to a code pen
https://codepen.io/jaylojkigert/pen/XWWEEPb
Thank You!
Video is great!
What software are you using for PHP coding in this video?
please tell me the name of application.
You're my hero man! Thank you <3
Dude, I am not gay or anything "But I love you" I admire people like you who can stop their lives and use their time to share knowledge this way… I always say the way to define people is by looking at their acts based on their knowledge and good will to look after the well being of others. A hug from Guatemala bro, and trust me, if you are not already doing great in life, I am pretty sure you will cause people like you only represent progress.
Hello there and thank you for posting these very interesting videos. I think that so far your tutorials are the most clear and easy to understand. On this particular lesson, I have typed all the html and php code exactly as it is on the correspondent file I downloaded to my computer and as you show on it. Everything is working accordingly. I have the two little text boxes for the num1 and num2 working perfectly. The Calculate button is there looking gorgeous and bright. Everything is ready to go, except that after I enter both numbers, choose an operator and click on the "Calculate" button, nothing happens. I don't get any answer after I perform the Calculate function. What am I doing wrong?
Thanku soo much sir
nice , but modules ?
hi did you have a tutorial for the PHP engine setup and which software you used for the webserver you place your php documents on?
This shitty calculator for so much of php and what not ????
11:51 Danish/Dansk ÆØÅ?
Thanks so much, very much, too much, for this explanation your channel is just on Top
Cheer up
Thank you so much from Germany(orginally from Iran:D)
What kind of keyboard are you using? Its loud.
Best course for php ever. thanks alot. from kurdistan-iraq
Hello guys, here is the solution using if statement instead of the switch. if($operator == "None"){
echo "True";
}elseif($operator == "Add"){
echo $result1 + $result2;
}elseif($operator == "Subtract"){
echo $result1 – $result2;
}elseif($operator == "Multiply") {
echo $result1 * $result2;
}else {
echo $result1 / $result2;
}
}
Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.39 (Win64) OpenSSL/1.1.1c PHP/7.3.8 please i need a suggestion on #15 any time i click the button to get the answer it keep poping up this 'obeject not found and error 404'
Nice, Short and Simple. Thanks!
I can't make calculations because my folder isn't taking the number. I repeated the code, but I can't do the math operations. Someone can help me?
How come does this channel doesn't have more visibility? Dude you're great! Thank you so much for your videos. Keep up the excellent work!
Thanks bro
Guys I'm stuck. I've got all the code right and my Wamp Server is on but it won't out put an answer. Im not sure what Ive done wrong. I even made sure the actual lesson is in the directory. It's pulling the file from my computer and not from the server. Please help.
loved it, it took me 3 days to come to this videos …im a initial advance js learner and i find both php and js similar
thanks your explanation is great
i dont get echo answer on browser and i dont get any error massage …
help me if you guys have answer
سلام. دوستان برای یادگیری برنامه نویسی وب به صورت کاربردی و ساده و روون به کانالم سر بزنید. اینم بگم ک کاملا پروژه محور میریم جلو با هم رشد میکنیم…
سلام. دوستان برای یادگیری برنامه نویسی وب به صورت کاربردی و ساده و روون به کانالم سر بزنید. اینم بگم ک کاملا پروژه محور میریم جلو با هم رشد میکنیم…
I slept while listening to you LMAO I can't believe…
It is actually so simple. Just take me a while until figured out how to install Xampp. Thanks.
it was much more simple then expected. thnx for helping me!
My button that says "Calculate" doesn't appear. Therefore, I cannot continue.
Can anyone help me to find the error in the code?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
</head>
<body>
<form>
<input type="text" name="num1" placeholder="Number1">
<input type="text" name="num2" placeholder="Number2">
<select name="operator">
<option>None</option>
<option>Add</option>
<option>Subtract</option>
<option>Multiply</option>
<option>Divide</option>
</selec>
<br>
<button type="submit" name="submit" value="submit">Calculate</button>
</form>
</body>
</html>
Thanks 🙂
my whatsapp number +233201191925
Thank you.
But, how can I calculate (minus) total income from a table from total expenses of difference table.