duanchu2607 2017-04-10 10:50
浏览 67

如何用PHP解析二进制文件

1.
Because all the data are stored in a computer in a binary format, consider the following instruction:

$string = "welcome to $name";

If we save php file in utf-8 encoding format, the instruction would be saved in the following form:

00100100 01110011 01110100 01110010 01101001 01101110 01100111 00100000 00111101 00100000 00100010 01110111 01100101 01101100 01100011 01101111 01101101 01100101 00100000 01110100 01101111 00100000 00100100 01101110 01100001 01101101 01100101 00100010 00111011 


When I open this file in an editor, I see the letters and signs etc. correctly but how does the php interpreter see the content?

Does it see the content in this form?

00100100 01110011 01110100 01110010 01101001 01101110 01100111 00100000 00111101 00100000 00100010 01110111 01100101 01101100 01100011 01101111 01101101 01100101 00100000 01110100 01101111 00100000 00100100 01101110 01100001 01101101 01100101 00100010 00111011 

Or, does it see instructions in this form?

$string = "01110111 01100101 01101100 01100011 01101111 01101101 01100101 00100000 01110100 01101111 00100000 00100100 01101110 01100001 01101101 01100101";

or:

$string = "01110111 01100101 01101100 01100011 01101111 01101101 01100101 00100000 01110100 01101111 00100000 $name";

or:

$string = "welcome to $name";

I do not exactly know how php sees the content of a program and what is does with the data.
If it does not see the content in a binary form, so when the string or integer and other data are converted to binary format?

2.
In php files, the header of php file is set on utf-8 by default. Also, we can set the encoding process in html files by making use of charset meta-tag. Encoding method can also be changed on the browser.

Now, the question is that whether the content sent by the server as a response to a browser is in a binary format or not? If the answer is negative, what is the use of encoding?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?