什么是C#ReadBytes(流语言)的PHP? [英] What is PHP for C# ReadBytes(stream langth)?

查看:75
本文介绍了什么是C#ReadBytes(流语言)的PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是C#的PHP(假设我们打开一些本地(服务器上)文件而不是OpenFileDialog

What is PHP for C# (asuming we open some local (on server) file instead of OpenFileDialog

        private const int HEADER_LENGTH = 13;
        stream = File.OpenRead(openFileDialog.FileName);
        header = ReadBytes(stream, HEADER_LENGTH);

下一步,我们将能够在PHP中执行类似的操作

And will we be able to do something like this in PHP as a next step

    private const byte SIGNATURE1 = 0x46;
    private const byte SIGNATURE2 = 0x4C;
    private const byte SIGNATURE3 = 0x56;
      if ((SIGNATURE1 != header[0]) || (SIGNATURE2 != header[1]) || (SIGNATURE3 != header[2]))
            throw new InvalidDataException("Not a valid FLV file!.");

推荐答案

嗯,我想您正在寻找类似的东西

Hmm, I think you look for something like that

$handle = fopen(FILE, 'r');
if ($handle)
{
    $head = fread ( $handle , 13 );
    if ($head[0] != chr (0x46)) ...
    ...
}

您当然可以为此签名创建常量,但可以这样:

Of course you can create constants for this signature, but this way:

define('SIG1', chr(0x46));

然后您可以照常使用它们: $ head [0] == SIG1 等.可以在定义常量时使用函数,包括常量名称和值.

then you can use them as normal: $head[0] == SIG1 etc. You can use functions when defining constants, for both constant names and values.

这篇关于什么是C#ReadBytes(流语言)的PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆