Search code examples
phpoopzend-framework

Passing variable with == in php function


I am working on a project which is previously coded by someone else before years.

I have come to a code where it is written as

$totalTime = $this->getTotalTime($transmissionType == "A", $log);

Here before calling this function I find $transmissionType and its value is M

now the function is defined as

public function getTotalTime($AutGears = false){}

Now $transmissionType = M means manual

Means $AutGears might be the same and $log might not be used.

But I do not get value M in $AutGears. The reason i find is use of == while passing paremeter in

$totalTime = $this->getTotalTime($transmissionType == "A", $log);

I haven't seen use of == like this before, but not sure does it really means anything? Or it is a type error?

If it does not mean anything then I will be removing it and my code will run perfect.

This code is quite old and written in 90s, so I am not sure does this really mean anything.


Solution

  • == returns a boolean value.

    $isAutomatic = $transmissionType == "A";  // true or false
    $totalTime = $this->getTotalTime($isAutomatic, $log);
    

    Does this way of writing it make more sense…?