S
S
Sergey2015-09-19 09:09:01
Perl
Sergey, 2015-09-19 09:09:01

What is the difference between XOR operators in php and perl?

Can you please tell me what is the difference between bitwise exclusive or in PHP and PERL and how can you reproduce the operation of this operator in Perl using php?
Porting the following code from perl to php, getting different results with the same input.
$test = ($password ^ $newchal);
UPD: for some reason in php it returns a string 2 times shorter than in perl and the beginning of the perl string matches the one returned by PHP
UPD: I read in the dock that pearl, if 2 arguments in ^ are of different lengths, the short value is filled with zero bits , now the question. I know what value I have is short, how can I add these zero bits to it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Pavlenko, 2015-09-19
@Akdmeh

They should work the same way (as they do in many other languages). If not, look at the variables themselves, they do not match in different code

A
Alexander, 2015-09-19
@OneFive

Check the types of variables.

N
Nadz Goldman, 2015-09-19
@nadz

In both php and perl this is the same: xor It's
just that perl doesn't forgive mistakes =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question