Hi,

I am trying to do what the getBytes() function does in java in php. I have looked everywhere, but the closest I have found is I think pack(). Is this correct and the closest function to it? If so, how would I use pack to do what getbytes does? i am trying to send data headers over the net to another server.

Thanks,

Karl

    What does getBytes() do?

    "Um, my old Java manuals are over in there somewhere," he drawled, waving a pale hand vaguely towards more dead tree than was generated in creating the Kyoto Accord. "It's a method in some object, of course - dunno which one off the top of my head: java.foo.bar or something. You're free to have a look."

    I looked at the stacks again. Somehow, the invitation made them look larger.

      www.php.net

      they have this really nice feature there where you can search to see if somethings's a pre-made function, and if so what it does and how, and even comment on usage

        Originally posted by m3rajk
        www.php.net



        they have this really nice feature there where you can search to see if somethings's a pre-made function, and if so what it does and how, and even comment on usage

        Yes, I searched there already - but as I already told you, there is no plain equivilent that I can see.. can you? I thought maybe pack, but not sure, hence why I post here.

          Characters in Java are stored as Unicode 16-bit sequences. In PHP they're single byte sequences. So getBytes() is pretty much a no-op. If you want to convert a string into an array of characters, then there's an example of how on the [man]preg_match[/man] page.

          If charsets are your issue, then the Multi-Byte String functions ([man]mbstring[/man]) are probably relevant to you.

            Write a Reply...