Recently I came to know that there is a slight difference in code behavior due to host platform.
$result = Data::my_custom_function($data, 'id');
//comment : my_custom_function($array, $id) --- it will return either false or string based on business logic
if($result)
{
return $result;
}
else
{
return false;
}
Above code runs fine with Windows if STRING is returned by function, but the same is not happening on CentOS server where the project is hosted.
It goes to else part even if there is string in $result
variable.
I had to change the code to follow to have it run on both:
if(!empty($result) && is_string($result) && strlen($result) > 0)
{
return $result;
}
else
{
return false;
}
Why it happened I have no idea. Maybe because Windows is bit soft on strict policy like file name you can write on upper/lower case it goes without issue but in Linux kernel filename must be exactly in lower/upper case as it is on the file system. Please help.
System Info:
Both server and Local machine are equipped with PHP-7.4.x
Localhost is Windows 10
Server is Cent OS 7.x