本文整理汇总了PHP中headers_sent函数的典型用法代码示例。如果您正苦于以下问题:PHP headers_sent函数的具体用法?PHP headers_sent怎么用?PHP headers_sent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了headers_sent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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.
}
}
示例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;
}
示例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;
}
示例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();
}
示例6: preprocess
public function preprocess()
{
if (!headers_sent()) {
header('Location: ../OpenBookFinancingV2/ObfWeeklyReportV2.php');
}
return false;
}
示例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'));
}
}
}
示例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;
}
示例9: redirect
public function redirect()
{
if (!headers_sent()) {
header('Content-Type: text/html; charset=UTF-8');
}
return parent::redirect();
}
示例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();
}
示例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'));
}
}
示例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);
}
示例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');
}
示例14: redirect
function redirect($url, $permanent = false)
{
if (headers_sent() === false) {
header('Location: ' . $url, true, $permanent === true ? 301 : 302);
}
exit;
}
示例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;
}
}