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


PHP ob_get_length函数代码示例

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


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

示例1: scriptReturn

function scriptReturn($return, $buffer = false, $json = true)
{
    global $initime;
    if ($buffer) {
        // start and end user output so this can happen without the user waiting
        ob_end_clean();
        header("Connection: close");
        ignore_user_abort();
        // optional
        ob_start();
    }
    if ($json) {
        $return['memory_usage'] = formatBytes(memory_get_usage());
        $return['memory_peak_usage'] = formatBytes(memory_get_peak_usage());
        $return['script_run_time'] = round((microtime(true) - $initime) * 1000);
        header('Content-Type: application/json');
        echo json_encode($return, JSON_NUMERIC_CHECK);
    } else {
        header('Content-Type: text/html');
        echo htmlArray($return);
    }
    if ($buffer) {
        $size = ob_get_length();
        header("Content-Length: {$size}");
        ob_end_flush();
        // Strange behaviour, will not work
        flush();
        // Unless both are called !
    }
}
开发者ID:debruine,项目名称:webmorph,代码行数:30,代码来源:main_func.php

示例2: ajax_widget_reports

 /**
  * Ajax handler for Admin Widget
  *
  * @return json|int
  */
 function ajax_widget_reports()
 {
     global $GADASH_Config;
     if (!isset($_REQUEST['gadash_security_widget_reports']) or !wp_verify_nonce($_REQUEST['gadash_security_widget_reports'], 'gadash_get_widgetreports')) {
         wp_die(-30);
     }
     $projectId = $_REQUEST['projectId'];
     $from = $_REQUEST['from'];
     $to = $_REQUEST['to'];
     $query = $_REQUEST['query'];
     if (ob_get_length()) {
         ob_clean();
     }
     $tools = new GADASH_Tools();
     if (!$tools->check_roles($GADASH_Config->options['ga_dash_access_back']) or 0 == $GADASH_Config->options['dashboard_widget']) {
         wp_die(-31);
     }
     if ($GADASH_Config->options['ga_dash_token'] and $projectId and $from and $to) {
         include_once $GADASH_Config->plugin_path . '/tools/gapi.php';
         global $GADASH_GAPI;
     } else {
         wp_die(-24);
     }
     $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
     if (isset($profile_info[4])) {
         $GADASH_GAPI->timeshift = $profile_info[4];
     } else {
         $GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
     }
     $GADASH_GAPI->get($projectId, $query, $from, $to);
 }
开发者ID:mrpixelart,项目名称:vision-fleet-deploy,代码行数:36,代码来源:ajax-actions.php

示例3: service

 public function service($request, $response)
 {/*{{{*/
     ob_start();
     $result = $this->callCenterApi->returnSuccess();
     $function = $request->service;
     if(method_exists($this, $function))
     {
         try
         {
             $lockName = $this->getLockerName($request);
             $cacher= DAL::get()->getCache(Cacher::CACHETYPE_LOCKER);
             $locker  = LockUtil::factory(LockUtil::LOCK_TYPE_MEMCACHE, array('memcache' => $cacher));
             $locker->getLock($lockName);
             $result = $this->$function($request,$response);
             $locker->releaseLock($lockName);
         }
         catch(LockException $ex)
         {
             error_log(XDateTime::now()->toString()."并发锁错误 $lockName\n", 3 , $this->logFileName);
         }
         catch(Exception $ex)
         {
             error_log(XDateTime::now()->toString()."释放锁 $lockName\n", 3 , $this->logFileName);
             $locker->releaseLock($lockName);
         }
     }
     echo $result;
     $this->logTxt .= XDateTime::now()->toString().'--->'.print_r($result, true)."\n";
     header('Content-Length: ' . ob_get_length());
     return parent::DIRECT_OUTPUT;
 }/*}}}*/
开发者ID:sdgdsffdsfff,项目名称:hdf-client,代码行数:31,代码来源:tinetcallcentercallbackcontroller.php

示例4: ierror

function ierror($msg, $code)
{
    global $logger;
    if ($code == 301 || $code == 302) {
        if (ob_get_length() !== FALSE) {
            ob_clean();
        }
        // default url is on html format
        $url = html_entity_decode($msg);
        $logger->warning($code . ' ' . $url, 'i.php', array('url' => $_SERVER['REQUEST_URI']));
        header('Request-URI: ' . $url);
        header('Content-Location: ' . $url);
        header('Location: ' . $url);
        exit;
    }
    if ($code >= 400) {
        $protocol = $_SERVER["SERVER_PROTOCOL"];
        if ('HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol) {
            $protocol = 'HTTP/1.0';
        }
        header("{$protocol} {$code} {$msg}", true, $code);
    }
    //todo improve
    echo $msg;
    $logger->error($code . ' ' . $msg, 'i.php', array('url' => $_SERVER['REQUEST_URI']));
    exit;
}
开发者ID:donseba,项目名称:Piwigo,代码行数:27,代码来源:i.php

示例5: clean_ob

 /**
  * starts new clean output buffer
  *
  * @access  public
  *
  * @author  patrick.kracht
  */
 public function clean_ob()
 {
     if (!ob_get_length() || !ob_get_level()) {
         ob_start();
     }
     session_cache_limiter('must-revalidate');
 }
开发者ID:Zurzeithier,项目名称:zeiterfassung-hs-ulm,代码行数:14,代码来源:template.php

示例6: vp_ajax_wrapper

 function vp_ajax_wrapper()
 {
     $function = $_POST['func'];
     $params = $_POST['params'];
     if (VP_Security::instance()->is_function_whitelisted($function)) {
         if (!is_array($params)) {
             $params = array($params);
         }
         try {
             $result['data'] = call_user_func_array($function, $params);
             $result['status'] = true;
             $result['message'] = __("Successful", 'vp_textdomain');
         } catch (Exception $e) {
             $result['data'] = '';
             $result['status'] = false;
             $result['message'] = $e->getMessage();
         }
     } else {
         $result['data'] = '';
         $result['status'] = false;
         $result['message'] = __("Unauthorized function", 'vp_textdomain');
     }
     if (ob_get_length()) {
         ob_clean();
     }
     header('Content-type: application/json');
     echo json_encode($result);
     die;
 }
开发者ID:cntlscrut,项目名称:bicyclepeddler2,代码行数:29,代码来源:bootstrap.php

示例7: render

 public function render($display = true)
 {
     $render = false;
     $this->pdf_renderer->setFontForLang(Context::getContext()->language->iso_code);
     foreach ($this->objects as $object) {
         $template = $this->getTemplateObject($object);
         if (!$template) {
             continue;
         }
         if (empty($this->filename)) {
             $this->filename = $template->getFilename();
             if (count($this->objects) > 1) {
                 $this->filename = $template->getBulkFilename();
             }
         }
         $template->assignHookData($object);
         $this->pdf_renderer->createHeader($template->getHeader());
         $this->pdf_renderer->createFooter($template->getFooter());
         $this->pdf_renderer->createContent($template->getContent());
         $this->pdf_renderer->writePage();
         $render = true;
         unset($template);
     }
     if ($render) {
         // clean the output buffer
         if (ob_get_level() && ob_get_length() > 0) {
             ob_clean();
         }
         return $this->pdf_renderer->render($this->filename, $display);
     }
 }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:31,代码来源:PDF.php

示例8: render

 /**
  * Render template
  * @var string Template to be rendered (optional)
  */
 public function render($template = '')
 {
     $template = is_string($template) ? $template . '.php' : null;
     if ($template) {
         $this->appendData(array('global' => $this->global));
         $content = parent::render($template);
     } else {
         $content = '';
     }
     // make sure buffers flushed
     ob_end_flush();
     if (ob_get_length() !== false) {
         ob_flush();
     }
     ob_start();
     extract(array('content' => $content, 'global' => $this->global));
     if ($this->layout) {
         $layoutPath = $this->getTemplatesDirectory() . '/' . ltrim($this->layout, '/');
         if (!is_readable($layoutPath)) {
             throw new RuntimeException('View cannot render layout `' . $layoutPath);
         }
         require $layoutPath;
     } else {
         echo $content;
     }
     return ob_get_clean();
 }
开发者ID:bra1nfuck,项目名称:blog.thyphoon.org,代码行数:31,代码来源:View.php

示例9: ierror

function ierror($msg, $code)
{
    if ($code == 301 || $code == 302) {
        if (ob_get_length() !== FALSE) {
            ob_clean();
        }
        // default url is on html format
        $url = html_entity_decode($msg);
        header('Request-URI: ' . $url);
        header('Content-Location: ' . $url);
        header('Location: ' . $url);
        ilog('WARN', $code, $url, $_SERVER['REQUEST_URI']);
        exit;
    }
    if ($code >= 400) {
        $protocol = $_SERVER["SERVER_PROTOCOL"];
        if ('HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol) {
            $protocol = 'HTTP/1.0';
        }
        header("{$protocol} {$code} {$msg}", true, $code);
    }
    //todo improve
    echo $msg;
    ilog('ERROR', $code, $msg, $_SERVER['REQUEST_URI']);
    exit;
}
开发者ID:HassenLin,项目名称:piwigo_utf8filename,代码行数:26,代码来源:i.php

示例10: after_output

 public function after_output()
 {
     # flush once, because we're nice
     if (QM_Util::is_ajax() and ob_get_length()) {
         ob_flush();
     }
 }
开发者ID:pfkellogg,项目名称:hooks_good_one,代码行数:7,代码来源:Headers.php

示例11: espresso_ical

 function espresso_ical()
 {
     do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
     $name = $_REQUEST['event_summary'] . ".ics";
     $output = "BEGIN:VCALENDAR\n" . "VERSION:2.0\n" . "PRODID:-//" . $_REQUEST['organization'] . " - Event Espresso Version " . espresso_version() . "//NONSGML v1.0//EN\n" . "METHOD:PUBLISH\n" . "X-WR-CALNAME:" . $_REQUEST['organization'] . "\n" . "X-ORIGINAL-URL:" . $_REQUEST['eereg_url'] . "\n" . "X-WR-CALDESC:" . $_REQUEST['organization'] . "\n" . "X-WR-TIMEZONE:" . get_option('timezone_string') . "\n" . "BEGIN:VEVENT\n" . "DTSTAMP:" . $_REQUEST['currentyear'] . $_REQUEST['currentmonth'] . $_REQUEST['currentday'] . "T" . $_REQUEST['currenttime'] . "\n" . "UID:" . $_REQUEST['registration_id'] . "@" . $_REQUEST['eereg_url'] . "\n" . "ORGANIZER:MAILTO:" . $_REQUEST['contact_email'] . "\n" . "DTSTART:" . $_REQUEST['startyear'] . $_REQUEST['startmonth'] . $_REQUEST['startday'] . "T" . $_REQUEST['starttime'] . "\n" . "DTEND:" . $_REQUEST['endyear'] . $_REQUEST['endmonth'] . $_REQUEST['endday'] . "T" . $_REQUEST['endtime'] . "\n" . "STATUS:CONFIRMED\n" . "URL:" . $_REQUEST['eereg_url'] . "\n" . "SUMMARY:" . $_REQUEST['event_summary'] . "\n" . "LOCATION:" . $_REQUEST['location'] . "\n" . "END:VEVENT\n" . "END:VCALENDAR";
     if (ob_get_length()) {
         echo 'Some data has already been output, can\'t send iCal file';
     }
     header('Content-Type: application/x-download');
     if (headers_sent()) {
         echo 'Some data has already been output, can\'t send iCal file';
     }
     header('Content-Length: ' . strlen($output));
     header('Content-Disposition: attachment; filename="' . $name . '"');
     header('Cache-Control: private, max-age=0, must-revalidate');
     header('Pragma: public');
     header('Content-Type: application/octet-stream');
     header('Content-Type: application/force-download');
     header('Content-type: application/pdf');
     header("Cache-Control: no-cache, must-revalidate");
     // HTTP/1.1
     header("Content-Transfer-Encoding: binary");
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     // Date in the past
     ini_set('zlib.output_compression', '0');
     echo $output;
     die;
 }
开发者ID:sriram911,项目名称:pls,代码行数:28,代码来源:ical.php

示例12: backup

 /**
  * @return SS_HTTPRequest
  */
 public function backup()
 {
     $name = 'assets_' . SS_DateTime::now()->Format('Y-m-d') . '.zip';
     $tmpName = TEMP_FOLDER . '/' . $name;
     $zip = new ZipArchive();
     if (!$zip->open($tmpName, ZipArchive::OVERWRITE)) {
         user_error('Asset Export Extension: Unable to read/write temporary zip archive', E_USER_ERROR);
         return;
     }
     $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(ASSETS_PATH, RecursiveDirectoryIterator::SKIP_DOTS));
     foreach ($files as $file) {
         $local = str_replace(ASSETS_PATH . '/', '', $file);
         $zip->addFile($file, $local);
     }
     if (!$zip->status == ZipArchive::ER_OK) {
         user_error('Asset Export Extension: ZipArchive returned an error other than OK', E_USER_ERROR);
         return;
     }
     $zip->close();
     if (ob_get_length()) {
         @ob_flush();
         @flush();
         @ob_end_flush();
     }
     @ob_start();
     $content = file_get_contents($tmpName);
     unlink($tmpName);
     return SS_HTTPRequest::send_file($content, $name);
 }
开发者ID:helpfulrobot,项目名称:stnvh-silverstripe-assetexport,代码行数:32,代码来源:AssetAdminExport.php

示例13: export

 public static function export()
 {
     // Set default handlers
     set_error_handler(array('Ai1wm_Error', 'error_handler'));
     set_exception_handler(array('Ai1wm_Error', 'exception_handler'));
     // Get options
     if (isset($_POST['options']) && ($options = $_POST['options'])) {
         $storage = new StorageArea();
         // Export archive
         $model = new Ai1wm_Export();
         $file = $model->export($storage, $options);
         // Send the file to the user
         header('Content-Description: File Transfer');
         header('Content-Type: application/octet-stream');
         header(sprintf('Content-Disposition: attachment; filename=%s-%s.%s', Ai1wm_Export::EXPORT_ARCHIVE_NAME, time(), 'zip'));
         header('Content-Transfer-Encoding: binary');
         header('Expires: 0');
         header('Cache-Control: must-revalidate');
         header('Pragma: public');
         header('Content-Length: ' . filesize($file->getAs('string')));
         // Clear output buffering and read file content
         if (ob_get_length() > 0) {
             @ob_end_clean();
         }
         readfile($file->getAs('string'));
         $storage->flush();
         exit;
     }
 }
开发者ID:easinewe,项目名称:Avec2016,代码行数:29,代码来源:class-ai1wm-export-controller.php

示例14: loadDatabaseDump

 public function loadDatabaseDump($dump, $flush = false, $force = false)
 {
     // newlines
     $dump = str_replace("\r", '', $dump);
     // clear comments
     $dump = preg_replace('/#.*#/', '', $dump);
     // get queries
     $queries = preg_split('/;\\n/', $dump);
     if ($flush && ob_get_length()) {
         ob_flush();
         ob_end_clean();
     }
     foreach ($queries as $query) {
         $query = trim($query);
         if (!empty($query)) {
             try {
                 ActiveRecord::executeUpdate($query);
             } catch (Exception $e) {
                 if (!$force) {
                     throw $e;
                 }
             }
         }
         if ($flush) {
             echo '.';
             flush();
         }
     }
     return true;
 }
开发者ID:saiber,项目名称:livecart,代码行数:30,代码来源:Installer.php

示例15: dump

 /**
  * Вывод содержимого переменной
  *
  * @param      $var
  * @param bool $return
  * @param bool $exit
  *
  * @return mixed|void
  */
 public static function dump($var, $return = false, $exit = true)
 {
     parent::$maxDepth = 15;
     ob_get_contents() || ob_get_length() ? ob_clean() : null;
     parent::dump($var, $return);
     !$exit ?: exit;
 }
开发者ID:argentum88,项目名称:owl-client,代码行数:16,代码来源:Debugger.php


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