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


PHP SplFileObject::fpassthru方法代码示例

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


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

示例1: getContents

 /**
  * Returns the contents of the file
  *
  * @return string the contents of the file
  */
 public function getContents()
 {
     $file = new \SplFileObject($this->getRealpath(), 'rb');
     ob_start();
     $file->fpassthru();
     return ob_get_clean();
 }
开发者ID:JPunto,项目名称:Symfony,代码行数:12,代码来源:SplFileInfo.php

示例2: loadAction

 /**
  * @Route("/download/{filename}/{file}", name="app_download")
  * @Route("/load/{filename}/{file}", name="app_load")
  * @ParamConverter("file", converter="file_converter")
  * @Method("GET")
  * @param string $filename
  * @param \SplFileObject $file
  * @return Response
  */
 public function loadAction($filename, \SplFileObject $file)
 {
     $response = new Response($file->fpassthru());
     $response->headers->set('Content-Type', 'octet/stream');
     $response->headers->set('Content-disposition', 'attachment; filename="' . $filename . '.' . $file->getExtension() . '";"');
     $response->headers->set('Content-Length', $file->getSize());
     $response->headers->set('Cache-Control', 'max-age=31536000, public');
     // 1 year
     $response->sendHeaders();
     return $response->send();
 }
开发者ID:zhooravell,项目名称:box-songs.com,代码行数:20,代码来源:AudioController.php

示例3: download

 public function download($path)
 {
     if (is_null($path) || empty($path)) {
         throw new InvalidArgumentException('You must specify the item to download.', 400);
     } else {
         if (!$this->exists($path) || !is_file($this->realRootDirectory . DIRECTORY_SEPARATOR . $path)) {
             throw new FileNotFoundException('The specified file does not exist.', 404);
         }
     }
     $fileObject = new \SplFileObject($this->realRootDirectory . DIRECTORY_SEPARATOR . $path);
     HttpResponse::setContentDisposition($fileObject->getBasename());
     HttpResponse::setContentType('application/octet-stream');
     HttpResponse::setHeader('Content-Length', $fileObject->getSize());
     $fileObject->fpassthru();
     exit(0);
 }
开发者ID:chriswells0,项目名称:cwa-lib,代码行数:16,代码来源:FileManager.php

示例4: explode

$versionPieces = explode(' ', $version);
$phalconVersion = $versionPieces[0];
define('EXAMPLES_DIR', sprintf("%s/%s/%s", dirname(__DIR__), 'interfaces', $phalconVersion));
$phalconClasses = new \RegexIterator(new \ArrayIterator(get_declared_interfaces()), '/^Phalcon/');
foreach ($phalconClasses as $phalconClass) {
    $reflector = new \ReflectionClass($phalconClass);
    $distillate = new Distillate();
    $distillate->setInterfaceName($phalconClass);
    $distillate->setExtendingInterfaces(implode(',\\', $reflector->getInterfaceNames()));
    $parentClass = $reflector->getParentClass();
    if ($parentClass) {
        $distillate->addParentClass($reflector->getParentClass()->getName());
    }
    $methodIterator = new \ArrayIterator($reflector->getMethods());
    foreach ($methodIterator as $method) {
        $distillate->addMethod($method);
    }
    $consts = $reflector->getConstants();
    $distillate->addConsts($consts);
    $fileName = sprintf('%s/%s.php', EXAMPLES_DIR, str_replace('\\', '/', $phalconClass));
    $fileName = str_replace('/Phalcon/', '/', $fileName);
    $dirName = dirname($fileName);
    is_dir($dirName) ?: mkdir($dirName, 0777, true);
    $file = new \SplFileObject($fileName, 'w');
    //$file   = new \SplTempFileObject( );
    $writer = new Distillate\Writer($file, true);
    $writer->writeToFile($distillate);
    $file->rewind();
    $file->fpassthru();
    echo $fileName . PHP_EOL;
}
开发者ID:aodkrisda,项目名称:phalcon-code,代码行数:31,代码来源:gen-interfaces.php

示例5: SplFileObject

<?php

$obj = new SplFileObject(dirname(__FILE__) . '/SplFileObject_testinput.csv');
$obj->fpassthru();
开发者ID:badlamer,项目名称:hhvm,代码行数:4,代码来源:SplFileObject_fpassthru_basic.php


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