11: Our First Exercise Using Object Oriented PHP Programming | OOP PHP Tutorial | Learn OOP PHP

Our First Exercise Using Object Oriented PHP Programming | OOP PHP Tutorial | Learn OOP PHP. In this PHP tutorial you will learn how to use object oriented PHP programming in a real project. The project you will create, is how to make a simple calculator in object oriented PHP programming.

➤ 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: https://www.patreon.com/posts/oop-php-11-16327509

Comments

Urbie LateNight Gaming Adventure says:

Notice: Undefined property: Calc::$Cal in C:xampphtdocstestoopincludescalc.inc.php on line 18
Error

< ?php class Calc{ public $num1; public $num2; public $cal; public function __construct($num1,$num2,$cal){ //gobal?? $this->num1 = $num1;
$this->num2 = $num2;
$this->cal = $cal;
}

public function calcMethod(){
switch($this->cal){ //line 18, this line
case ‘add’:
$result = $this->num1 + $this->num2;
break;

case ‘sub’:
$result = $this->num1 – $this->num2;
break;

case ‘mul’:
$result = $this->num1 * $this->num2;
break;

default:
$result = “Error”;
break;

}
return $result;
}

}

mohamed gaber says:

i get as output 2 what ever what i do any idea ??

1 2 says:

Great series.

Yoan Rodriguez says:

My code is returning the “Error” message and below the calculator which works just fine. Why is returning the default if the calculator is working just fine?

Dominus Providebit says:

So… I had a quick question, I noticed you teach A LOT in all kinds of different languages. I was wondering how long it took you to be able to work with OOP php? what is the regular learning time for a programmer ?

leonil dayado says:

Wow! awesome tutorial

Armando Corales Bogayan Jr says:

good tutorial seems like i’m starting learning and exploring PHP oop , this make the separation of concern, reusable function if it’s needed 😀

Dorian Sabo says:

Hey Daniel, i have one question. I noticed that we don’t need to declare $num1,$num2 and $cal in Calc class, it is going to work wihtout it. Well, why we are doing this? Is it for better understanding, readability or pest practice?

Curtis Miles says:

Awesome tutorials!

winy mule says:

I have figured out the problem, I had made a mistake with the $cal variable, its okay now

Cent Ci says:

wow! very nice; thanks for teaching us always

winy mule says:

my calculator is returning an error, I tried to instead of returning an error as the default I decided to add two numbers as the default case and I noticed that its returning 0, and I dont understand why, everything seems to be in place, I even checked if the post method is working and it is, the variables are being passed down, but the switch isnt taking in the values I need your help

Surin Farmwest says:

I do hate to pick holes but @11:38 2-1 – refresh =3 …. Or are my old eyes playing tricks?

Romy Kim says:

I have a question and looked upto #11 to get answer. #12 seemed a bit off topic for my question. Both -> and :: are like . operator in Java. I now have clear understanding of the difference, thanks to you. But… what is => ? You haven’t covered it in OOP series, and… I saw them in Wordpess. Something like…. $args = array (‘theme_location’ => ‘primary’); …. is an example where menus (as page) gets located for their nature. Is that => anything similar to -> or :: ? Or is it something unrelated ? It kinda looks like (and actually is) assigning instruction. Thanks again.

Vincent Ho says:

Great and easy to follow.

Thanks

Cymburyo Ox says:

do you have to use __construct and __deconstruct in every class?

Jeb Bush says:

THanks for the video. Can you please create a fully functional Social Network in PHP, jq, javascript, ajax, or vue.js, using the MVC design pattern. Thank you

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!