Andy-H Posted November 9, 2011 Share Posted November 9, 2011 Just wondering if anyone knew of one? I have been looking for ages but can't find what I need. In java: public class Test { public static void main(String[] args) { System.out.println((byte)0xff); } } Outputs: -1 I've tried things like <?php $var = pack('H', 0xff); echo $var; ?> But that doesn't output anything Quote Link to comment https://forums.phpfreaks.com/topic/250777-is-there-an-equivalent-to-java-cast-to-byte-in-php/ Share on other sites More sharing options...
Adam Posted November 9, 2011 Share Posted November 9, 2011 There is no byte data type in PHP, you just need to use string: echo (string) 0xff; Quote Link to comment https://forums.phpfreaks.com/topic/250777-is-there-an-equivalent-to-java-cast-to-byte-in-php/#findComment-1286655 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.