0

Alright so is there any way to have strict variables in PHP? Or well their types like in C#.

Example

class test {
      public int $myInt = 5;
      public bool $myBool = true;
      public string $myString = "This is a string";
}

and if so how?

Also if its possible, is there any benefit from this? Im asking since I know lots of languages use datatypes for variables and I never seen in PHP.

I have tried using this on my own localhost and did some research but I ended up with errors when I tried to execute this code

Tomislav Tomi Nikolic
  • 608
  • 3
  • 10
  • 15

0 Answers0