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 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; 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
Archived
This topic is now archived and is closed to further replies.