當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。