$valOne variable has string type value and $valTwo variable has original value. I calculated them and did not find error as I excepted.
$valOne = "100"; //defined variable as string.
$valTwo = 6; //defined variable as value.
$calOfVals = $valOne / $valTwo; //applied division.
echo $calOfVals; //output: 16.666666666667.
Top comments (2)
As Sophie mentioned php is not strictly typed. The most common way to add strict typing is to add
declare(strict_types=1);
at the top of php files.But this will not fix your code, because you didn't give php type information.
If you create a function with type hinting then it will give an error.
PHP isn't as strictly typed as other languages. You will get a warning if you at least turn on strict types and can promote that to an error I believe in your php configs. Its been a while since I did PHP but I know in classes now you can type the member variable but I'm not sure about regular variables.