When casting a string to an integer, any numeric characters up to the first non-numeric character becomes the number. Thus '1234 test'
becomes 1234
because space is not a numeric character.
Thus 1234 == '1234 test'
If you want to force a string comparison, you should cast to string:
''.(1234) == '1234 test' // implicit
(string) 1234 == '1234 test' // explicit
strval(1234) == '1234 test' // procedural