当前位置: 首页>>代码示例>>PHP>>正文


PHP Reader::read方法代码示例

本文整理汇总了PHP中Reader::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Reader::read方法的具体用法?PHP Reader::read怎么用?PHP Reader::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Reader的用法示例。


在下文中一共展示了Reader::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructs the class with given parameters.
  *
  * @param Zend_Io_Reader $reader The reader object.
  * @param Array          $options The options array.
  */
 public function __construct($reader)
 {
     $this->_reader = $reader;
     if (!in_array($this->_packetType = $this->_reader->readUInt8(), array(1, 3, 5))) {
         require_once 'Zend/Media/Vorbis/Exception.php';
         throw new Zend_Media_Vorbis_Exception('Unknown header packet type: ' . $this->_packetType);
     }
     if (($vorbis = $this->_reader->read(6)) != 'vorbis') {
         require_once 'Zend/Media/Vorbis/Exception.php';
         throw new Zend_Media_Vorbis_Exception('Unknown header packet: ' . $vorbis);
     }
     $skipBytes = $this->_reader->getCurrentPagePosition();
     for ($page = $this->_reader->getCurrentPageNumber();; $page++) {
         $segments = $this->_reader->getPage($page)->getSegmentTable();
         for ($i = 0, $skippedSegments = 0; $i < count($segments); $i++) {
             // Skip page segments that are already read in
             if ($skipBytes > $segments[$i]) {
                 $skipBytes -= $segments[$i];
                 continue;
             }
             // Skip segments that are full
             if ($segments[$i] == 255 && ++$skippedSegments) {
                 continue;
             }
             // Record packet size from the first non-255 segment
             $this->_packetSize += $i * 255 + $segments[$i];
             break 2;
         }
         $this->_packetSize += $skippedSegments * 255;
     }
 }
开发者ID:google-code-backups,项目名称:php-reader,代码行数:37,代码来源:Header.php

示例2: testWorkaround

    function testWorkaround()
    {
        // See https://github.com/fruux/sabre-vobject/issues/36
        $event = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
SUMMARY:Titel
SEQUENCE:1
TRANSP:TRANSPARENT
RRULE:FREQ=YEARLY
LAST-MODIFIED:20130323T225737Z
DTSTAMP:20130323T225737Z
UID:1833bd44-188b-405c-9f85-1a12105318aa
CATEGORIES:Jubiläum
X-MOZ-GENERATION:3
RECURRENCE-ID;RANGE=THISANDFUTURE;VALUE=DATE:20131013
DTSTART;VALUE=DATE:20131013
CREATED:20100721T121914Z
DURATION:P1D
END:VEVENT
END:VCALENDAR
ICS;
        $obj = Reader::read($event);
        // If this does not throw an exception, it's all good.
        $it = new Recur\EventIterator($obj, '1833bd44-188b-405c-9f85-1a12105318aa');
        $this->assertInstanceOf('Sabre\\VObject\\Recur\\EventIterator', $it);
    }
开发者ID:ddolbik,项目名称:sabre-vobject,代码行数:28,代码来源:Issue36WorkAroundTest.php

示例3: testGetDTEnd

    function testGetDTEnd()
    {
        $ics = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//iCal 4.0.4//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
TRANSP:OPAQUE
DTEND;TZID=America/New_York:20070925T170000
UID:uuid
DTSTAMP:19700101T000000Z
LOCATION:
DESCRIPTION:
STATUS:CONFIRMED
SEQUENCE:18
SUMMARY:Stuff
DTSTART;TZID=America/New_York:20070925T160000
CREATED:20071004T144642Z
RRULE:FREQ=MONTHLY;INTERVAL=1;UNTIL=20071030T035959Z;BYDAY=5TU
END:VEVENT
END:VCALENDAR
ICS;
        $vObject = Reader::read($ics);
        $it = new RecurrenceIterator($vObject, (string) $vObject->VEVENT->UID);
        while ($it->valid()) {
            $it->next();
        }
        // If we got here, it means we were successful. The bug that was in teh
        // system before would fail on the 5th tuesday of the month, if the 5th
        // tuesday did not exist.
    }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:32,代码来源:RecurrenceIteratorFifthTuesdayProblemTest.php

示例4: prevStartCode

 /**
  * Finds and returns the previous start code. Start codes are reserved bit
  * patterns in the video file that do not otherwise occur in the video
  * stream.
  *
  * All start codes are byte aligned and start with the following byte
  * sequence: 0x00 0x00 0x01.
  *
  * @return integer
  */
 protected final function prevStartCode()
 {
     $buffer = '    ';
     $start;
     $position = $this->_reader->getOffset();
     while ($position > 0) {
         $start = 0;
         $position = $position - 512;
         if ($position < 0) {
             require_once 'Zend/Media/Mpeg/Exception.php';
             throw new Zend_Media_Mpeg_Exception('Invalid data');
         }
         $this->_reader->setOffset($position);
         $buffer = $this->_reader->read(512) . substr($buffer, 0, 4);
         $pos = 512 - 8;
         while ($pos > 3) {
             list(, $int) = unpack('n*', substr($buffer, $pos + 1, 2));
             if (ord($buffer[$pos]) == 0 && $int == 1) {
                 list(, $int) = unpack('n*', substr($buffer, $pos + 3, 2));
                 if ($pos + 2 < 512 && $int == 0 && ord($buffer[$pos + 5]) == 1) {
                     $pos--;
                     continue;
                 }
                 $this->_reader->setOffset($position + $pos);
                 return ord($buffer[$pos + 3]) & 0xff | 0x100;
             }
             $pos--;
         }
         $this->_reader->setOffset($position = $position + 3);
     }
     return 0;
 }
开发者ID:jreinert,项目名称:RuneUI,代码行数:42,代码来源:Object.php

示例5: assertVObjEquals

 /**
  * This method tests wether two vcards or icalendar objects are
  * semantically identical.
  *
  * It supports objects being supplied as strings, streams or
  * Sabre\VObject\Component instances.
  *
  * PRODID is removed from both objects as this is often changes and would
  * just get in the way.
  *
  * CALSCALE will automatically get removed if it's set to GREGORIAN.
  *
  * Any property that has the value **ANY** will be treated as a wildcard.
  *
  * @param resource|string|Component $expected
  * @param resource|string|Component $actual
  * @param string $message
  */
 function assertVObjEquals($expected, $actual, $message = '')
 {
     $self = $this;
     $getObj = function ($input) use($self) {
         if (is_resource($input)) {
             $input = stream_get_contents($input);
         }
         if (is_string($input)) {
             $input = Reader::read($input);
         }
         if (!$input instanceof Component) {
             $this->fail('Input must be a string, stream or VObject component');
         }
         unset($input->PRODID);
         if ($input instanceof Component\VCalendar && (string) $input->CALSCALE === 'GREGORIAN') {
             unset($input->CALSCALE);
         }
         return $input;
     };
     $expected = $getObj($expected)->serialize();
     $actual = $getObj($actual)->serialize();
     // Finding wildcards in expected.
     preg_match_all('|^([A-Z]+):\\*\\*ANY\\*\\*\\r$|m', $expected, $matches, PREG_SET_ORDER);
     foreach ($matches as $match) {
         $actual = preg_replace('|^' . preg_quote($match[1], '|') . ':(.*)\\r$|m', $match[1] . ':**ANY**' . "\r", $actual);
     }
     $this->assertEquals($expected, $actual, $message);
 }
开发者ID:ddolbik,项目名称:sabre-vobject,代码行数:46,代码来源:TestCase.php

示例6: testRead

    function testRead()
    {
        $input = <<<VCF
BEGIN:VCARD
VERSION:2.1
N:Doe;Jon;;;
FN:Jon Doe
EMAIL;X-INTERN:foo@example.org
UID:foo
END:VCARD
VCF;
        $vcard = Reader::read($input);
        $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $vcard);
        $vcard = $vcard->convert(\Sabre\VObject\Document::VCARD30);
        $vcard = $vcard->serialize();
        $converted = Reader::read($vcard);
        $converted->validate();
        $this->assertTrue(isset($converted->EMAIL['X-INTERN']));
        $version = Version::VERSION;
        $expected = <<<VCF
BEGIN:VCARD
VERSION:3.0
PRODID:-//Sabre//Sabre VObject {$version}//EN
N:Doe;Jon;;;
FN:Jon Doe
EMAIL;X-INTERN=:foo@example.org
UID:foo
END:VCARD

VCF;
        $this->assertEquals($expected, str_replace("\r", "", $vcard));
    }
开发者ID:vernonlacerda,项目名称:jorani,代码行数:32,代码来源:EmptyParameterTest.php

示例7: fgetcsv_reg

 /**
  * fgetcsvの代替メソッド
  * @param string $d = ',' CSV区切り文字
  * @param string $e = '"' CSV文字列囲み文字
  * @return array 読み出したCSV配列
  * @access private
  */
 private function fgetcsv_reg($d = ',', $e = '"')
 {
     $d = preg_quote($d);
     $e = preg_quote($e);
     $_line = "";
     while ($eof != true) {
         $__line = parent::read();
         if ($__line === false) {
             break;
         } else {
             $_line .= $__line;
         }
         $itemcnt = preg_match_all('/' . $e . '/', $_line, $dummy);
         if ($itemcnt % 2 == 0) {
             $eof = true;
         }
     }
     $_csv_line = preg_replace('/(?:\\r\\n|[\\r\\n])?$/', $d, trim($_line));
     $_csv_pattern = '/(' . $e . '[^' . $e . ']*(?:' . $e . $e . '[^' . $e . ']*)*' . $e . '|[^' . $d . ']*)' . $d . '/';
     preg_match_all($_csv_pattern, $_csv_line, $_csv_matches);
     $_csv_data = $_csv_matches[1];
     for ($_csv_i = 0; $_csv_i < count($_csv_data); $_csv_i++) {
         $_csv_data[$_csv_i] = preg_replace('/^' . $e . '(.*)' . $e . '$/s', '$1', $_csv_data[$_csv_i]);
         $_csv_data[$_csv_i] = str_replace($e . $e, $e, $_csv_data[$_csv_i]);
     }
     return preg_replace('/(?:\\r\\n|[\\r\\n])?$/', '', trim($_line)) === '' ? false : $_csv_data;
 }
开发者ID:weiweiabc109,项目名称:test_project1,代码行数:34,代码来源:CsvReader.class.php

示例8: __construct

 /**
  * Constructs the ID3v1 class with given file. The file is not mandatory
  * argument and may be omitted. A new tag can be written to a file also by
  * giving the filename to the {@link #write} method of this class.
  *
  * @param string $filename The path to the file.
  */
 public function __construct($filename = false)
 {
     if (($this->_filename = $filename) === false || file_exists($filename) === false) {
         return;
     }
     $this->_reader = new Reader($filename);
     if ($this->_reader->getSize() < 128) {
         return;
     }
     $this->_reader->setOffset(-128);
     if ($this->_reader->read(3) != "TAG") {
         $this->_reader = false;
         // reset reader, see write
         return;
     }
     $this->_title = rtrim($this->_reader->readString8(30), " ");
     $this->_artist = rtrim($this->_reader->readString8(30), " ");
     $this->_album = rtrim($this->_reader->readString8(30), " ");
     $this->_year = $this->_reader->readString8(4);
     $this->_comment = rtrim($this->_reader->readString8(28), " ");
     /* ID3v1.1 support for tracks */
     $v11_null = $this->_reader->read(1);
     $v11_track = $this->_reader->read(1);
     if (ord($v11_null) == 0 && ord($v11_track) != 0) {
         $this->_track = ord($v11_track);
     } else {
         $this->_comment = rtrim($this->_comment . $v11_null . $v11_track, " ");
     }
     $this->_genre = $this->_reader->readInt8();
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:37,代码来源:ID3v1.php

示例9: exampleWrapInNamespace

 /**
  * Wrap code in namespace
  *
  * @expectOutputRegex #namespace Foo#
  */
 public function exampleWrapInNamespace()
 {
     $reader = new Reader("<?php class Bar {}");
     $writer = new Writer();
     $writer->apply(new Action\NamespaceWrapper('Foo'));
     // Outputs class Bar wrapped in namespace Foo
     echo $writer->write($reader->read('Bar'));
 }
开发者ID:bonroyage,项目名称:classtools,代码行数:13,代码来源:TransformerExamples.php

示例10: testRead

 function testRead()
 {
     $vcard = Reader::read(file_get_contents(dirname(__FILE__) . '/issue64.vcf'));
     $vcard = $vcard->convert(\Sabre\VObject\Document::VCARD30);
     $vcard = $vcard->serialize();
     $converted = Reader::read($vcard);
     $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $converted);
 }
开发者ID:bodun,项目名称:jorani,代码行数:8,代码来源:Issue64Test.php

示例11: parse

 /**
  * Starts the parsing process.
  *
  * @param  string  the option to set
  * @return int     1 if the parsing succeeded
  * @throws ExpatParseException if something gone wrong during parsing
  * @throws IOException if XML file can not be accessed
  * @access public
  */
 function parse()
 {
     while (($data = $this->reader->read()) !== -1) {
         if (!xml_parse($this->parser, $data, $this->reader->eof())) {
             $error = xml_error_string(xml_get_error_code($this->parser));
             $e = new ExpatParseException($error, $this->getLocation());
             xml_parser_free($this->parser);
             throw $e;
         }
     }
     xml_parser_free($this->parser);
     return 1;
 }
开发者ID:namesco,项目名称:phing,代码行数:22,代码来源:ExpatParser.php

示例12: testRead

    function testRead()
    {
        $event = <<<ICS
BEGIN:VCALENDAR
BEGIN:VEVENT
ATTACH;FMTTYPE=;ENCODING=:Zm9v
END:VEVENT
END:VCALENDAR

ICS;
        $obj = Reader::read($event);
        $this->assertEquals($event, $obj->serialize());
    }
开发者ID:bodun,项目名称:jorani,代码行数:13,代码来源:AttachIssueTest.php

示例13: testRead

    function testRead()
    {
        $event = <<<ICS
BEGIN:VCALENDAR
BEGIN:VEVENT
DESCRIPTION:TEST\\n\\n \\n\\nTEST\\n\\n \\n\\nTEST\\n\\n \\n\\nTEST\\n\\nTEST\\nTEST, TEST
END:VEVENT
END:VCALENDAR

ICS;
        $obj = Reader::read($event);
        $this->assertEquals($event, $obj->serialize());
    }
开发者ID:bodun,项目名称:jorani,代码行数:13,代码来源:LineFoldingIssueTest.php

示例14: testRead

    function testRead()
    {
        $input = <<<VCF
BEGIN:VCARD
VERSION:2.1
SOURCE:Yahoo Contacts (http://contacts.yahoo.com)
URL;CHARSET=utf-8;ENCODING=QUOTED-PRINTABLE:=
http://www.example.org
END:VCARD
VCF;
        $vcard = Reader::read($input, Reader::OPTION_FORGIVING);
        $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $vcard);
        $this->assertEquals("http://www.example.org", $vcard->URL->getValue());
    }
开发者ID:linagora,项目名称:sabre-vobject,代码行数:14,代码来源:Issue96Test.php

示例15: testDecodeValue

    function testDecodeValue()
    {
        $input = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DESCRIPTION:This is a descpription\\nwith a linebreak and a \\; \\, and :
END:VEVENT
END:VCALENDAR
ICS;
        $vobj = Reader::read($input);
        // Before this bug was fixed, getValue() would return nothing.
        $this->assertEquals("This is a descpription\nwith a linebreak and a ; , and :", $vobj->VEVENT->DESCRIPTION->getValue());
    }
开发者ID:bodun,项目名称:jorani,代码行数:14,代码来源:EmptyValueIssueTest.php


注:本文中的Reader::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。