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


PHP fflush函数代码示例

本文整理汇总了PHP中fflush函数的典型用法代码示例。如果您正苦于以下问题:PHP fflush函数的具体用法?PHP fflush怎么用?PHP fflush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: generateCsv

 public function generateCsv(View $view)
 {
     $columns = $view->getExportableCols();
     $titles = array_map(function (Column $col) {
         return $col->label;
     }, $columns);
     $colNames = array_map(function (Column $col) {
         return $col->id;
     }, $columns);
     // get rows
     $sql = $view->prepareQuery();
     $rows = \Meta\Core\Db::query($sql)->fetchAll(\PDO::FETCH_ASSOC);
     header("Content-type: text/csv");
     header("Content-Disposition: attachment; filename=export.csv");
     header("Pragma: no-cache");
     header("Expires: 0");
     // write CSV to output
     $stdout = fopen('php://output', 'w');
     fputcsv($stdout, $titles);
     foreach ($rows as $row) {
         $newRow = array();
         foreach ($colNames as $name) {
             $newRow[$name] = $row[$name];
         }
         fputcsv($stdout, $newRow);
     }
     fflush($stdout);
     fclose($stdout);
     exit;
 }
开发者ID:moiseh,项目名称:metapages,代码行数:30,代码来源:CsvExporter.php

示例2: log_msg

/**
 *	log a message to file
 *
 *	@param string $level can be error, warn, info or debug
 *	@param string $msg message
 *	@return bool true if successful, false if not
 */
function log_msg($level, $msg)
{
    global $logfile;
    global $loglevels;
    global $request_id;
    // open logfile
    if ($logfile === false) {
        $m = umask(0111);
        // having two processes appending to the same file should
        // work fine (at least on Linux)
        $logfile = @fopen(LOG_FILE, 'ab');
        umask($m);
    }
    if ($logfile === false) {
        return false;
    }
    foreach ($loglevels as $ll) {
        if ($ll == $level) {
            fwrite($logfile, date('Y-m-d H:i:s') . tab() . pad($_SERVER['REMOTE_ADDR'], 15) . tab() . sprintf('%05u', $request_id) . tab() . $level . tab() . $msg . nl());
            fflush($logfile);
            break;
        }
        if ($ll == LOG_LEVEL) {
            break;
        }
    }
    return true;
}
开发者ID:danielfogarty,项目名称:damp,代码行数:35,代码来源:log.inc.php

示例3: flush

 public function flush()
 {
     $r = fflush($this->__f);
     if ($r === false) {
         throw new HException(haxe_io_Error::Custom("An error occurred"));
     }
 }
开发者ID:marcdraco,项目名称:Webrathea,代码行数:7,代码来源:FileOutput.class.php

示例4: getContent

 /**
  * Create content from template and data.
  *
  * @param string $name
  * @param array $data
  *
  * @return string|null
  */
 public function getContent($name, array $data = [])
 {
     $path = $this->packageRoot . '/view/_cache/' . str_replace('/', '_', $name);
     if (!file_exists($path) || !$this->cache) {
         $code = $this->compile($name, true, true);
         if (empty($code)) {
             return null;
         }
         $fh = fopen($path, 'wb');
         if (flock($fh, LOCK_EX)) {
             fwrite($fh, $code);
             flock($fh, LOCK_UN);
         }
         fflush($fh);
         fclose($fh);
     }
     $fh = fopen($path, 'rb');
     flock($fh, LOCK_SH);
     if (null !== $this->request) {
         $data = array_replace($data, ['request' => $this->request]);
     }
     $html = self::renderTemplate($path, $data);
     flock($fh, LOCK_UN);
     fclose($fh);
     return $html;
 }
开发者ID:dspbee,项目名称:pivasic,代码行数:34,代码来源:Native.php

示例5: Run

 public static function Run()
 {
     echo 'relocate ' . register__xampp::$name . PHP_EOL;
     fflush(STDOUT);
     self::relocateShortcut();
     return;
 }
开发者ID:TheSkyNet,项目名称:railoapacheportable,代码行数:7,代码来源:package__xampp.php

示例6: setupSeo

 public function setupSeo()
 {
     if (file_exists('../.htaccess')) {
         return;
     } else {
         if (function_exists('apache_get_modules')) {
             $modules = apache_get_modules();
             $mod_rewrite = in_array('mod_rewrite', $modules);
         } else {
             $mod_rewrite = getenv('HTTP_MOD_REWRITE') == 'On' ? true : false;
         }
         if ($mod_rewrite && file_exists('../.htaccess.txt')) {
             chmod('../.htaccess.txt', 0777);
             $file = fopen('../.htaccess.txt', 'a');
             $document = file_get_contents('../.htaccess.txt');
             $root = rtrim(HTTP_SERVER, '/');
             $folder = substr(strrchr($root, '/'), 1);
             $path = rtrim(rtrim(dirname($_SERVER['SCRIPT_NAME']), ''), '/' . $folder . '.\\');
             if (strlen($path) > 1) {
                 $path .= '/';
             }
             if (!$path) {
                 $path = '/';
             }
             $document = str_replace('RewriteBase /', 'RewriteBase ' . $path, $document);
             file_put_contents('../.htaccess.txt', $document);
             fflush($file);
             fclose($file);
             rename('../.htaccess.txt', '../.htaccess');
         }
     }
     clearstatcache();
 }
开发者ID:ahmatjan,项目名称:OpenCart-Overclocked,代码行数:33,代码来源:system.php

示例7: appendNamespace

function appendNamespace($inputFilename, $namespace, $outputFilename)
{
    $inputHandle = fopen($inputFilename, "r") or die("Unable to open file to read!");
    $outputHandle = fopen($outputFilename, "w") or die("Unable to open file to write!");
    while (!feof($inputHandle)) {
        $buffer = fgets($inputHandle);
        //readline
        $startpos = strpos($buffer, '<?php');
        //        print '--'.$startpos.'--';
        if (is_int($startpos)) {
            $starttaglen = 5;
            $headlen = strlen(trim($buffer));
            if ($headlen == $starttaglen) {
                fwrite($outputHandle, $buffer);
                fwrite($outputHandle, "namespace {$namespace};" . PHP_EOL);
            } else {
                $header = substr($buffer, 0, $startpos + $starttaglen);
                $tail = substr($buffer, $startpos + $starttaglen);
                fwrite($outputHandle, $header . PHP_EOL);
                print 'header:' . $buffer . PHP_EOL;
                fwrite($outputHandle, "namespace {$namespace};" . PHP_EOL);
                fwrite($outputHandle, $tail . PHP_EOL);
            }
            break;
        }
    }
    while (!feof($inputHandle)) {
        $buffer = fgets($inputHandle);
        //readline
        fwrite($outputHandle, $buffer);
    }
    fflush($outputHandle);
    fclose($inputHandle);
    fclose($outputHandle);
}
开发者ID:fishlab,项目名称:alipay-sdk-php,代码行数:35,代码来源:append_namespace.php

示例8: saveFile

 public static function saveFile($loc, $dsc, $zip = false)
 {
     if (function_exists(curl_init)) {
         if (file_exists($dsc)) {
             unlink($dsc);
         }
         $f1 = @fopen($dsc, "w");
         $ch = curl_init($loc);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_FILE, $f1);
         if ($zip) {
             curl_setopt($ch, CURLOPT_ENCODING, 'gzip , deflate');
         }
         if (curl_errno($ch) != 0 || curl_getinfo($ch, CURLINFO_HTTP_CODE) > 403) {
             curl_close($ch);
             fclose($f1);
             return false;
         }
         curl_exec($ch);
         curl_close($ch);
         fflush($f1);
         fclose($f1);
         return true;
     }
 }
开发者ID:CrazyBobik,项目名称:allotaxi.test,代码行数:28,代码来源:inet.php

示例9: logEvent

function logEvent($logLine, $logType = LOG_INFO)
{
    global $logFile, $useSysLog, $logFd, $auth;
    $attr = array();
    if (isset($auth['name'])) {
        $attr[] = $auth['name'];
    }
    if (isset($_SERVER['REMOTE_ADDR'])) {
        $attr[] = $_SERVER['REMOTE_ADDR'];
    }
    if (count($attr)) {
        $logLine = '[' . implode(", ", $attr) . '] ' . $logLine;
    }
    if ($logType == LOG_ERR) {
        $logLine = 'error: ' . $logLine;
    }
    if ($useSysLog) {
        syslog($logType, $logLine);
    } elseif (!isset($logFd)) {
        if ($logType == LOG_ERR) {
            error_log('DL: ' . $logLine);
        }
    } else {
        $logLine = "[" . date(DATE_W3C) . "] {$logLine}\n";
        flock($logFd, LOCK_EX);
        fseek($logFd, 0, SEEK_END);
        fwrite($logFd, $logLine);
        fflush($logFd);
        flock($logFd, LOCK_UN);
    }
}
开发者ID:dg-wfk,项目名称:dl,代码行数:31,代码来源:funcs.php

示例10: do_request

 /**
  * A single request, without following redirects
  *
  * @todo: Handle redirects? If so, only for GET (i.e. not for POST), and use G2's
  * WebHelper_simple::_parseLocation logic.
  */
 static function do_request($url, $method = 'GET', $headers = array(), $body = '')
 {
     if (!array_key_exists("User-Agent", $headers)) {
         $headers["User-Agent"] = "Gallery3";
     }
     /* Convert illegal characters */
     $url = str_replace(' ', '%20', $url);
     $url_components = self::_parse_url_for_fsockopen($url);
     $handle = fsockopen($url_components['fsockhost'], $url_components['port'], $errno, $errstr, 5);
     if (empty($handle)) {
         // log "Error $errno: '$errstr' requesting $url";
         return array(null, null, null);
     }
     $header_lines = array('Host: ' . $url_components['host']);
     foreach ($headers as $key => $value) {
         $header_lines[] = $key . ': ' . $value;
     }
     $success = fwrite($handle, sprintf("%s %s HTTP/1.0\r\n%s\r\n\r\n%s", $method, $url_components['uri'], implode("\r\n", $header_lines), $body));
     if (!$success) {
         // Zero bytes written or false was returned
         // log "fwrite failed in requestWebPage($url)" . ($success === false ? ' - false' : ''
         return array(null, null, null);
     }
     fflush($handle);
     /*
      * Read the status line.  fgets stops after newlines.  The first line is the protocol
      * version followed by a numeric status code and its associated textual phrase.
      */
     $response_status = trim(fgets($handle, 4096));
     if (empty($response_status)) {
         // 'Empty http response code, maybe timeout'
         return array(null, null, null);
     }
     /* Read the headers */
     $response_headers = array();
     while (!feof($handle)) {
         $line = trim(fgets($handle, 4096));
         if (empty($line)) {
             break;
         }
         /* Normalize the line endings */
         $line = str_replace("\r", '', $line);
         list($key, $value) = explode(':', $line, 2);
         if (isset($response_headers[$key])) {
             if (!is_array($response_headers[$key])) {
                 $response_headers[$key] = array($response_headers[$key]);
             }
             $response_headers[$key][] = trim($value);
         } else {
             $response_headers[$key] = trim($value);
         }
     }
     /* Read the body */
     $response_body = '';
     while (!feof($handle)) {
         $response_body .= fread($handle, 4096);
     }
     fclose($handle);
     return array($response_status, $response_headers, $response_body);
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:66,代码来源:MY_remote.php

示例11: flush_output

function flush_output()
{
    $output = ob_get_contents();
    rewind($GLOBALS['ob_file']);
    fwrite($GLOBALS['ob_file'], $output);
    fflush($GLOBALS['ob_file']);
}
开发者ID:rifkiferdian,项目名称:gtfw_boostab,代码行数:7,代码来源:00init.php

示例12: W

 function W($aStr)
 {
     if (fwrite($this->iFP, $aStr) == -1) {
         die("Can't write to file : " . $this->iFileName);
     }
     fflush($this->iFP);
 }
开发者ID:wahgithub,项目名称:chits_wah_emr,代码行数:7,代码来源:jpgenhtmldoc.php

示例13: flushReport

 public function flushReport($auth, $report)
 {
     if (is_null($auth) || is_null($report)) {
         if ($this->_verbose > 0) {
             error_log("Auth or report not set.");
         }
         return null;
     }
     if ($this->_verbose >= 3) {
         var_dump($report);
     }
     $content = json_encode($report);
     $content = gzencode($content);
     $header = "Host: " . $this->_host . "\r\n";
     $header .= "User-Agent: LightStep-PHP\r\n";
     $header .= "LightStep-Access-Token: " . $auth->access_token . "\r\n";
     $header .= "Content-Type: application/json\r\n";
     $header .= "Content-Length: " . strlen($content) . "\r\n";
     $header .= "Content-Encoding: gzip\r\n";
     $header .= "Connection: keep-alive\r\n\r\n";
     // Use a persistent connection when possible
     $fp = @pfsockopen($this->_host, $this->_port, $errno, $errstr);
     if (!$fp) {
         if ($this->_verbose > 0) {
             error_log($errstr);
         }
         return null;
     }
     @fwrite($fp, "POST /api/v0/reports HTTP/1.1\r\n");
     @fwrite($fp, $header . $content);
     @fflush($fp);
     @fclose($fp);
     return null;
 }
开发者ID:lightstep,项目名称:lightstep-tracer-php,代码行数:34,代码来源:TransportHTTPJSON.php

示例14: SaveForDebug

function SaveForDebug($debugStr)
{
    $logFile = fopen(DEBUG_FILE, 'a');
    if (flock($logFile, LOCK_EX | LOCK_NB)) {
        $serverInfo = var_export($_SERVER, true);
        $str = date('d M H:i:s', CURRENT_TIME);
        if (isset($_SERVER['REMOTE_ADDR'])) {
            $str .= ' - ip ' . $_SERVER['REMOTE_ADDR'];
            if (isset($_SERVER['HTTP_REFERER'])) {
                $str .= ' - ref ' . $_SERVER['HTTP_REFERER'];
            }
            if (isset($_SERVER['HTTP_USER_AGENT'])) {
                $str .= ' - ua ' . $_SERVER['HTTP_USER_AGENT'];
            }
        }
        $str .= "\ndebug: {$debugStr}\n\n{$serverInfo}\n\n";
        if (count($_POST)) {
            $str .= "\n" . var_export($_POST, true) . "\n";
        }
        fwrite($logFile, $str . "\n\n");
        fflush($logFile);
        flock($logFile, LOCK_UN);
    }
    fclose($logFile);
}
开发者ID:sc2tvru-main,项目名称:chat-sc2tv,代码行数:25,代码来源:utils.php

示例15: flush

 /**
  * {@inheritDoc}
  */
 public function flush()
 {
     if ($this->fileHandle) {
         return fflush($this->fileHandle);
     }
     return false;
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:10,代码来源:Local.php


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