In Java, I can easily cast a number to a byte, for example:
System.err.println((byte) 13020);
the result will be
-36
Now how can I achieve the same in PHP?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Maybe do a modulo 256 expression (if unsigned) or modulo 256 and minus 128.
This work if you only want a value. If you want a real-one-byte, maybe pack() function will help here.
Edit: Right, 0 would be 128, so maybe this solution do will works: