不同的服务器,不同的数据类型与完全相同的代码

I'm running a code getting data from a DB server, everything is working fine locally. But when I push it online, it's not working anymore.

I think I know where the problem comes from. Here is the data I get locally:

object(stdClass)#451 (14) {
  ["matter_created_actionstep_c"]=>
  string(1) "1"
  ["trust_receipt_sent_c"]=>
  string(1) "1"
  ["scope_complete_c"]=>
  string(1) "0"
  ["transferred_trust_to_current_c"]=>
  string(1) "0"
}

And when I push it on my server, here is the result I get:

object(stdClass)#451 (14) {
 ["matter_created_actionstep_c"]=>
  int(1)
  ["trust_receipt_sent_c"]=>
  int(1)
  ["scope_complete_c"]=>
  int(0)
  ["transferred_trust_to_current_c"]=>
  int(0)
}

Are you aware of any apache configuration that would lead to this typeset change?

The only project file that is different, is the conf file:

locally:

DB_HOST=1.1.1.1

on the server:

DB_HOST=localhost

Thanks in advance.

This can result from a lot of issues. Maybe a different PHP version, maybe the data comes from a database and the version of the database driver is different, …

I would say the application is to blame. PHP is untyped, meaning in most cases nobody cares for the actual type of a variable. In your case barely anybody cares if the value is 2 or "2" as long as it behaves the same (e.g. 2==2 equals 2=="2"). If the application requires certain types in some variables, it should assure the variables contain these types! This is not the case here.

Check the application and the part of the code which writes the value into the object. This part of code should cast the value to the desired type before putting it into the variable.

Nevertheless (or if the object comes from somewhere else) it may make sense to make the code more forgiving concerning types, i.e. do not rely on a special type as long as it is not necessary. In my experience there are only few cases when type of variables really matter.