I am converting a working C++ program to php. Now even though most of the program works I am having trouble with one aspect of it.
The code that works in C++ is not giving the same results in php. This is for writing to a binary file later in my code.
Here is the C++ code and the result.
C++
char test;
test = 16;
test+=(char)131;
std::cout << (int)test << endl;
Result = -109
and here is the equivalent code in php.
PHP
$test = chr(0);
$test = 16;
$test+= chr(131);
echo (int)$test;
Result = 16
I am guessing this might have something to do with unicode encoding giving me the wrong result. The result should be -109 as my C++ program works correctly, but I am not getting the same result in php.
When I cout (int)(char)131 in C++ I get -125, but if I echo chr(131) in php I get 0;
Is there anyway to make my php output the same as my C++?