• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP headers_sent函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: start

 public static function start($lifetime = 0, $path = '/', $domain = NULL)
 {
     if (!self::$_initialized) {
         if (!is_object(Symphony::Database()) || !Symphony::Database()->connected()) {
             return false;
         }
         $cache = Cache::instance()->read('_session_config');
         if (is_null($cache) || $cache === false) {
             self::create();
             Cache::instance()->write('_session_config', true);
         }
         if (!session_id()) {
             ini_set('session.save_handler', 'user');
             ini_set('session.gc_maxlifetime', $lifetime);
             ini_set('session.gc_probability', '1');
             ini_set('session.gc_divisor', '3');
         }
         session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'gc'));
         session_set_cookie_params($lifetime, $path, $domain ? $domain : self::getDomain(), false, false);
         if (strlen(session_id()) == 0) {
             if (headers_sent()) {
                 throw new Exception('Headers already sent. Cannot start session.');
             }
             session_start();
         }
         self::$_initialized = true;
     }
     return session_id();
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:29,代码来源:class.session.php


示例2: prepareEnvironment

 /**
  * @ignore
  * @param array $options
  */
 public function prepareEnvironment($options = array())
 {
     if (empty($options['skipErrorHandler'])) {
         set_error_handler(array('Ip\\Internal\\ErrorHandler', 'ipErrorHandler'));
     }
     if (empty($options['skipError'])) {
         if (ipConfig()->showErrors()) {
             error_reporting(E_ALL | E_STRICT);
             ini_set('display_errors', '1');
         } else {
             ini_set('display_errors', '0');
         }
     }
     if (empty($options['skipSession'])) {
         if (session_id() == '' && !headers_sent()) {
             //if session hasn't been started yet
             session_name(ipConfig()->get('sessionName'));
             if (!ipConfig()->get('disableHttpOnlySetting')) {
                 ini_set('session.cookie_httponly', 1);
             }
             session_start();
         }
     }
     if (empty($options['skipEncoding'])) {
         mb_internal_encoding(ipConfig()->get('charset'));
     }
     if (empty($options['skipTimezone'])) {
         date_default_timezone_set(ipConfig()->get('timezone'));
         //PHP 5 requires timezone to be set.
     }
 }
开发者ID:x33n,项目名称:ImpressPages,代码行数:35,代码来源:Application.php


示例3: exceptionHandle

 public static function exceptionHandle(Exception $exception)
 {
     if (DEBUG_MODE) {
         //直接输出调试信息
         echo nl2br($exception->__toString());
         echo '<hr /><p>Router:</p><pre>';
         print_r(Singleton::getInstance('Router'));
         echo '</pre>';
     } else {
         $code = $exception->getCode();
         $message = nl2br($exception->getMessage());
         /*
                     如果错误码"可能为"合法的http状态码则尝试设置,
                     setStatus()方法会忽略非法的http状态码. */
         if ($code >= 400 && $code <= 505 && !headers_sent()) {
             ResponseModule::setStatus($code);
         }
         $var_list = array('message' => $message, 'code' => $code, 'file' => $exception->getFile(), 'url' => Singleton::getInstance('Router')->getUrl());
         if ($error_file = self::_getErrorFilePath($code)) {
             Lugit::$view = new View($var_list);
             Lugit::$view->render($error_file);
         } else {
             echo 'No error page is found.<pre>';
             print_r($var_list);
             echo '</pre>';
         }
     }
     exit;
 }
开发者ID:sujinw,项目名称:php-lugit-framework,代码行数:29,代码来源:Basic.php


示例4: render

 /**
  * Display the given exception to the user.
  *
  * @param   object  $exception
  * @return  void
  */
 public function render(Exception $error)
 {
     if (!headers_sent()) {
         header('HTTP/1.1 500 Internal Server Error');
     }
     $response = 'Error: ' . $error->getCode() . ' - ' . $error->getMessage() . "\n\n";
     if ($this->debug) {
         $backtrace = $error->getTrace();
         if (is_array($backtrace)) {
             $backtrace = array_reverse($backtrace);
             for ($i = count($backtrace) - 1; $i >= 0; $i--) {
                 if (isset($backtrace[$i]['class'])) {
                     $response .= "\n[{$i}] " . sprintf("%s %s %s()", $backtrace[$i]['class'], $backtrace[$i]['type'], $backtrace[$i]['function']);
                 } else {
                     $response .= "\n[{$i}] " . sprintf("%s()", $backtrace[$i]['function']);
                 }
                 if (isset($backtrace[$i]['file'])) {
                     $response .= sprintf(' @ %s:%d', str_replace(PATH_ROOT, '', $backtrace[$i]['file']), $backtrace[$i]['line']);
                 }
             }
         }
     }
     echo php_sapi_name() == 'cli' ? $response : nl2br($response);
     exit;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:31,代码来源:Plain.php


示例5: redirect

 public function redirect($uri = null, array $params = [])
 {
     if (headers_sent()) {
         Exception::toss('Cannot redirect to "%s" from the view because output has already started.', $uri);
     }
     (new RequestUri($this->format($uri, $params)))->redirect();
 }
开发者ID:europaphp,项目名称:component-view,代码行数:7,代码来源:Uri.php


示例6: preprocess

 public function preprocess()
 {
     if (!headers_sent()) {
         header('Location: ../OpenBookFinancingV2/ObfWeeklyReportV2.php');
     }
     return false;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:7,代码来源:ObfWeeklyReport.php


示例7: init

 function init($dir = null)
 {
     if ($dir != null) {
         $this->setdir($dir);
     }
     $this->group('settings');
     $this->group('global');
     $this->group('modules');
     $this->group('custom');
     @ini_set('default_charset', '');
     if (!headers_sent()) {
         viscacha_header('Content-type: text/html; charset=' . $this->phrase('charset'));
     }
     global $slog;
     if (isset($slog) && is_object($slog) && method_exists($slog, 'setlang')) {
         $slog->setlang($this->phrase('fallback_no_username'), $this->phrase('timezone_summer'));
     }
     global $config, $breadcrumb;
     if (isset($breadcrumb)) {
         $isforum = array('addreply', 'attachments', 'edit', 'forum', 'manageforum', 'managetopic', 'misc', 'newtopic', 'pdf', 'search', 'showforum', 'showtopic');
         if ($config['indexpage'] != 'forum' && in_array(SCRIPTNAME, $isforum)) {
             $breadcrumb->Add($this->phrase('forumname'), iif(SCRIPTNAME != 'forum', 'forum.php'));
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:25,代码来源:class.language.php


示例8: espresso_ical

function espresso_ical()
{
    $name = $_REQUEST['event_summary'] . ".ics";
    $output = "BEGIN:VCALENDAR\n" . "PRODID:-//xyz Corp//NONSGML PDA Calendar Version 1.0//EN\n" . "VERSION:2.0\n" . "BEGIN:VEVENT\n" . "DTSTAMP:" . $_REQUEST['currentyear'] . $_REQUEST['currentmonth'] . $_REQUEST['currentday'] . "T" . $_REQUEST['currenttime'] . "\n" . "UID:" . $_REQUEST['attendee_id'] . "@" . $_REQUEST['event_id'] . "\n" . "ORGANIZER:MAILTO:" . $_REQUEST['contact'] . "\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" . "CATEGORIES:" . $_REQUEST['event_categories'] . "\n" . "SUMMARY:" . $_REQUEST['event_summary'] . "\n" . "DESCRIPTION:" . $_REQUEST['event_description'] . "\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:macconsultinggroup,项目名称:WordPress,代码行数:27,代码来源:ical.php


示例9: redirect

 public function redirect()
 {
     if (!headers_sent()) {
         header('Content-Type: text/html; charset=UTF-8');
     }
     return parent::redirect();
 }
开发者ID:recca0120,项目名称:omnipay-allpay,代码行数:7,代码来源:AbstractResponse.php


示例10: __toString

 /**
  * Override __toString() to send HTTP Content-Type header
  *
  * @return string
  */
 public function __toString()
 {
     if (!headers_sent()) {
         header('Content-Type: text/xml; charset=' . strtolower($this->getEncoding()));
     }
     return parent::__toString();
 }
开发者ID:fredcido,项目名称:cenbrap,代码行数:12,代码来源:Http.php


示例11: download

 public function download()
 {
     $file = DIR_LOGS . $this->config->get('config_error_filename');
     clearstatcache();
     if (file_exists($file) && is_file($file)) {
         if (!headers_sent()) {
             if (filesize($file) > 0) {
                 header('Content-Type: application/octet-stream');
                 header('Content-Description: File Transfer');
                 header('Content-Disposition: attachment; filename=' . str_replace(' ', '_', $this->config->get('config_name')) . '_' . date('Y-m-d_H-i-s', time()) . '_error.log');
                 header('Content-Transfer-Encoding: binary');
                 header('Expires: 0');
                 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                 header('Pragma: public');
                 header('Content-Length: ' . filesize($file));
                 readfile($file, 'rb');
                 exit;
             }
         } else {
             exit('Error: Headers already sent out!');
         }
     } else {
         $this->redirect($this->url->link('tool/error_log', 'token=' . $this->session->data['token'], 'SSL'));
     }
 }
开发者ID:ahmatjan,项目名称:OpenCart-Overclocked,代码行数:25,代码来源:error_log.php


示例12: _printJson

 /**
  * Output object as JSON and set appropriate headers
  * @param mixed $object
  */
 protected function _printJson($object)
 {
     if (!headers_sent()) {
         header("Content-type: application/json");
     }
     echo json_encode($object);
 }
开发者ID:phemmyster,项目名称:phproject,代码行数:11,代码来源:controller.php


示例13: __construct

 function __construct()
 {
     parent::__construct();
     if (RSFormProHelper::isJ16()) {
         JHTML::_('behavior.framework');
     }
     if (!headers_sent()) {
         header('Content-type: text/html; charset=utf-8');
     }
     $this->_db = JFactory::getDBO();
     $doc =& JFactory::getDocument();
     $doc->addScript(JURI::root(true) . '/administrator/components/com_rsform/assets/js/jquery.js?v=40');
     $doc->addScript(JURI::root(true) . '/administrator/components/com_rsform/assets/js/tablednd.js?v=40');
     $doc->addScript(JURI::root(true) . '/administrator/components/com_rsform/assets/js/jquery.scrollto.js?v=40');
     $doc->addScript(JURI::root(true) . '/administrator/components/com_rsform/assets/js/script.js?v=41');
     $doc->addStyleSheet(JURI::root(true) . '/administrator/components/com_rsform/assets/css/style.css?v=42');
     if (RSFormProHelper::isJ16()) {
         $doc->addStyleSheet(JURI::root(true) . '/administrator/components/com_rsform/assets/css/style16.css?v=40');
     }
     $this->registerTask('formsApply', 'formsSave');
     $this->registerTask('formsPublish', 'formsChangeStatus');
     $this->registerTask('formsUnpublish', 'formsChangeStatus');
     $this->registerTask('componentsPublish', 'componentsChangeStatus');
     $this->registerTask('componentsUnpublish', 'componentsChangeStatus');
     $this->registerTask('configurationApply', 'configurationSave');
     $this->registerTask('submissionsExportCSV', 'submissionsExport');
     $this->registerTask('submissionsExportExcel', 'submissionsExport');
     $this->registerTask('submissionsExportXML', 'submissionsExport');
     $this->registerTask('submissionsApply', 'submissionsSave');
     $this->registerTask('submissionsSave', 'submissionsSave');
     $this->registerTask('richtextApply', 'richtextSave');
     $this->registerTask('emailApply', 'emailSave');
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:33,代码来源:controller.php


示例14: redirect

function redirect($url, $permanent = false)
{
    if (headers_sent() === false) {
        header('Location: ' . $url, true, $permanent === true ? 301 : 302);
    }
    exit;
}
开发者ID:JohnEmerson,项目名称:warehouse-inventory-system,代码行数:7,代码来源:functions.php


示例15: JsHttpRequest

 /**
  * Constructor.
  * 
  * Create new JsHttpRequest backend object and attach it
  * to script output buffer. As a result - script will always return
  * correct JavaScript code, even in case of fatal errors.
  */
 function JsHttpRequest($enc)
 {
     // QUERY_STRING is in form: PHPSESSID=<sid>&a=aaa&b=bbb&<id>
     // where <id> is request ID, <sid> - session ID (if present),
     // PHPSESSID - session parameter name (by default = "PHPSESSID").
     // Parse QUERY_STRING wrapper format.
     if (preg_match('/^(.*)(?:&|^)JsHttpRequest=(\\d+)-([^&]+)((?:&|$).*)$/s', $_SERVER['QUERY_STRING'], $m)) {
         $this->ID = $m[2];
         $this->LOADER = strtolower($m[3]);
         $_SERVER['QUERY_STRING'] = $m[1] . $m[4];
         unset($_GET['JsHttpRequest']);
         unset($_REQUEST['JsHttpRequest']);
     } else {
         $this->ID = 0;
         $this->LOADER = 'unknown';
     }
     // Start OB handling early.
     $this->_uniqHash = md5(microtime() . getmypid());
     ini_set('error_prepend_string', ini_get('error_prepend_string') . $this->_uniqHash);
     ini_set('error_append_string', ini_get('error_append_string') . $this->_uniqHash);
     ob_start(array(&$this, "_obHandler"));
     // Set up encoding.
     $this->setEncoding($enc);
     // Check if headers are already sent (see Content-Type library usage).
     // If true - generate debug message and exit.
     $file = $line = null;
     if (headers_sent($file, $line)) {
         trigger_error("HTTP headers are already sent" . ($line !== null ? " in {$file} on line {$line}" : "") . ". " . "Possibly you have extra spaces (or newlines) before first line of the script or any library. " . "Please note that Subsys_JsHttpRequest uses its own Content-Type header and fails if " . "this header cannot be set. See header() function documentation for details", E_USER_ERROR);
         exit;
     }
 }
开发者ID:space77,项目名称:mwfv3_sp,代码行数:38,代码来源:Php.php


示例16: page_handler

/**
 * Routes the request to a registered page handler
 *
 * This function sets the context based on the handler name (first segment of the
 * URL). It also triggers a plugin hook 'route', $handler so that plugins can
 * modify the routing or handle a request.
 *
 * @param string $handler The name of the handler type (eg 'blog')
 * @param array  $page    The parameters to the page, as an array (exploded by '/' slashes)
 *
 * @return bool
 * @access private
 */
function page_handler($handler, $page)
{
    global $CONFIG;
    elgg_set_context($handler);
    $page = explode('/', $page);
    // remove empty array element when page url ends in a / (see #1480)
    if ($page[count($page) - 1] === '') {
        array_pop($page);
    }
    // return false to stop processing the request (because you handled it)
    // return a new $params array if you want to route the request differently
    $params = array('handler' => $handler, 'segments' => $page);
    $params = elgg_trigger_plugin_hook('route', $handler, NULL, $params);
    if ($params === false) {
        return true;
    }
    $handler = $params['handler'];
    $page = $params['segments'];
    $result = false;
    if (isset($CONFIG->pagehandler) && !empty($handler) && isset($CONFIG->pagehandler[$handler])) {
        $function = $CONFIG->pagehandler[$handler];
        $result = call_user_func($function, $page, $handler);
    }
    return $result || headers_sent();
}
开发者ID:nachopavon,项目名称:Elgg,代码行数:38,代码来源:pagehandler.php


示例17: mpr

/**
 * My print_r - debug function
 * @author Oliwier Ptak (https://github.com/oliwierptak)
 *
 * Usage example:
 * mpr($mixed);
 * mpr($mixed,1); <- stop execution of the script
 * mpr($mixed,1,1); <- stop execution and show backtrace
 */
function mpr($val, $die = false, $showTrace = false)
{
    if (!headers_sent()) {
        header("content-type: text/plain");
    }
    echo '--MPR--';
    if (is_array($val) || is_object($val)) {
        print_r($val);
        if (is_array($val)) {
            reset($val);
        }
    } else {
        var_dump($val);
    }
    if ($showTrace || $die) {
        $trace = debug_backtrace();
        echo "--\n";
        echo sprintf("Who called me: %s line %s", $trace[0]['file'], $trace[0]['line']);
        if ($showTrace) {
            echo "\nTrace:";
            for ($i = 1; $i <= 100; $i++) {
                if (!isset($trace[$i])) {
                    break;
                }
                echo sprintf("\n%s line %s", $trace[$i]['file'], $trace[$i]['line']);
            }
        }
    }
    echo "\n";
    if ($die) {
        die;
    }
}
开发者ID:romannowicki,项目名称:mpr,代码行数:42,代码来源:mpr.php


示例18: setUp

    public function setUp()
    {
        $savePath = ini_get('session.save_path');
        if (strpos($savePath, ';')) {
            $savePath = explode(';', $savePath);
            $savePath = array_pop($savePath);
        }
        if (empty($savePath)) {
            $this->markTestSkipped('Cannot test FlashMessenger due to unavailable session save path');
        }

        if (headers_sent()) {
            $this->markTestSkipped('Cannot test FlashMessenger: cannot start session because headers already sent');
        }
        Zend_Session::start();

        $this->front      = Zend_Controller_Front::getInstance();
        $this->front->resetInstance();
        $this->front->setControllerDirectory(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . '_files');
        $this->front->returnResponse(true);
        $this->request    = new Zend_Controller_Request_Http();
        $this->request->setControllerName('helper-flash-messenger');
        $this->response   = new Zend_Controller_Response_Cli();
        $this->controller = new HelperFlashMessengerController($this->request, $this->response, array());
        $this->helper     = new Zend_Controller_Action_Helper_FlashMessenger($this->controller);
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:26,代码来源:FlashMessengerTest.php


示例19: startSession

 /**
  * Starts the session if it does not exist.
  *
  * @return void
  */
 protected function startSession()
 {
     // Check that the session hasn't already been started
     if (session_id() == '' && !headers_sent()) {
         session_start();
     }
 }
开发者ID:gitfreengers,项目名称:larus,代码行数:12,代码来源:NativeSession.php


示例20: db_error

 /** Display the error code and error message to the user if a database error occurred.
  *  The error must be read by the child method. This method will call a backtrace so
  *  you see the script and specific line in which the error occurred.
  *  @param $code    The database error code that will be displayed.
  *  @param $message The database error message that will be displayed.
  *  @return Will exit the script and returns a html output with the error informations.
  */
 public function db_error($code = 0, $message = '')
 {
     global $g_root_path, $gMessage, $gPreferences, $gCurrentOrganization, $gDebug, $gL10n;
     $htmlOutput = '';
     $backtrace = $this->getBacktrace();
     // Rollback on open transaction
     if ($this->transactions > 0) {
         $this->rollback();
     }
     if (!headers_sent() && isset($gPreferences) && defined('THEME_SERVER_PATH')) {
         // create html page object
         $page = new HtmlPage($gL10n->get('SYS_DATABASE_ERROR'));
     }
     // transform the database error to html
     $error_string = '<div style="font-family: monospace;">
                      <p><b>S Q L - E R R O R</b></p>
                      <p><b>CODE:</b> ' . $code . '</p>
                      ' . $message . '<br /><br />
                      <b>B A C K T R A C E</b><br />
                      ' . $backtrace . '
                      </div>';
     $htmlOutput = $error_string;
     // in debug mode show error in log file
     if ($gDebug === 1) {
         error_log($code . ': ' . $message);
     }
     // display database error to user
     if (!headers_sent() && isset($gPreferences) && defined('THEME_SERVER_PATH')) {
         $page->addHtml($htmlOutput);
         $page->show();
     } else {
         echo $htmlOutput;
     }
     exit;
 }
开发者ID:bash-t,项目名称:admidio,代码行数:42,代码来源:dbcommon.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP heading函数代码示例发布时间:2022-05-15
下一篇:
PHP headers_list函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap