本文整理汇总了PHP中add::content_type方法的典型用法代码示例。如果您正苦于以下问题:PHP add::content_type方法的具体用法?PHP add::content_type怎么用?PHP add::content_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类add
的用法示例。
在下文中一共展示了add::content_type方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: var_dump
/**
* XMP Var Dump
* var_dump with <xmp>
* @author albertdiones@gmail.com
* @since ADD MVC 0.0
*/
static function var_dump()
{
$args = func_get_args();
if (!$args) {
$args[0] = static::get_declared_globals();
}
$var = call_user_func_array('self::return_var_dump', $args);
if (add::content_type() == 'text/plain') {
$output = "\r\nFile Line:" . self::caller_file_line() . "\r\n" . $var . "\r\n";
} else {
$output = "<div style='clear:both'><b>" . self::caller_file_line() . "</b><xmp>" . $var . "</xmp></div>";
}
self::restricted_echo($output);
return $args[0];
}
示例2: array
<?php
require '../config.php';
require_once "{$C->add_dir}/init.php";
$exceptions = array('e_developer', 'e_syntax', 'e_hack', 'e_spam', 'e_system');
$exception = (string) $_GET['exception'];
$email = (string) $_GET['email'];
if ($exception) {
if ($_REQUEST['is_live']) {
add::environment_status('live');
}
add::content_type($_REQUEST['content_type']);
e_add::$email_addresses = $email;
$e = new $exception("Test Error Message");
#debug::var_dump($e->mail_body());
throw $e;
}
?>
<form method="GET">
<select name="exception">
<option><?php
echo implode("</option><option>", $exceptions);
?>
</option>
</select>
<label>Email<input type="text" name="email" /></label>
<label><input name="is_live" type="checkbox" />Live</label>
<label>
Content Type<select name="content_type">
<option>text/html</option>
<option>text/plain</option>
示例3: handle_exception
/**
* handle_exception()
* The error handler for exceptions
* @param Exception $e the exception to handle
* @since ADD MVC 0.0
*/
static function handle_exception(Exception $e)
{
try {
while (ob_get_level()) {
# Do not echo this, it is a big security risk
ob_get_clean();
}
try {
if (method_exists($e, 'handle_exception')) {
return $e->handle_exception();
} else {
throw new Exception("Non e_add exception sub class or no handle_exception() function found for exception");
}
} catch (Exception $e2) {
if ($e instanceof SmartyException) {
static::handle_exception(new e_smarty($e->getMessage(), array('message' => $e->getMessage(), 'code' => $e->getCode(), 'trace' => str_replace(array(add::config()->root_dir, add::config()->add_dir), array('*root_dir*', '*add_dir*'), $e->getTraceAsString()))));
}
if (add::content_type() == 'text/plain') {
die(get_class($e) . "(#" . $e->getCode() . ")\r\n\r\n" . $e->getMessage() . "\r\n\r\n" . $e->getFile() . ":" . $e->getLine() . "\r\n\r\n\r\n\r\n");
} else {
if (add::is_developer()) {
DEFINE('add\\terminal_error\\error_message', $e->getMessage());
DEFINE('add\\terminal_error\\error_trace', $e->getTraceAsString());
DEFINE('add\\terminal_error\\error_header', get_class($e));
DEFINE('add\\terminal_error\\error_footer', $e->getFile() . ":" . $e->getLine());
} else {
$debug_mail_to = add::config()->developer_emails;
if (is_array($debug_mail_to) || is_object($debug_mail_to)) {
$debug_mail_to = implode(",", (array) $debug_mail_to);
}
mail($debug_mail_to, "Terminal Error: " . $e->getMessage(), $e->getTraceAsString());
DEFINE('add\\terminal_error\\error_message', 'An error occured<br />please contact the system administrators or go back to <a href="' . add::config()->path . '">Home</a>');
DEFINE('add\\terminal_error\\error_header', 'Warning!');
DEFINE('add\\terminal_error\\error_footer', 'Please contact the system administrators');
DEFINE('add\\terminal_error\\error_trace', '');
}
if (!headers_sent() && !add::include_include_file('terminal_error.php')) {
throw new Exception("Failed to display terminal error");
}
add::shutdown(false);
}
}
} catch (Exception $e3) {
$e1_string = "<div style='color:red'>" . get_class($e) . "(#" . $e->getCode() . ")" . $e->getMessage() . "\r\n" . $e->getFile() . ":" . $e->getLine() . "</div>";
echo $e1_string;
$e3_string = "<div style='color:red'>" . get_class($e3) . "(#" . $e3->getCode() . ")" . $e3->getMessage() . "\r\n" . $e3->getFile() . ":" . $e3->getLine() . "</div>";
if ($e3_string != $e1_string) {
echo $e3_string;
}
debug::var_dump($e3->getTraceAsString());
die;
}
}
示例4: content_type
/**
* sets the content_type or get the current one
*
* @param string $new_content_type
*
* @deprecated see add::content_type();
*
* @since ADD MVC 0.8
*/
public function content_type($new_content_type = null)
{
return add::content_type($new_content_type);
}
示例5: DEFINE
*/
DEFINE('ADD_MIN_PHP_VERSION', '5.3.8');
if (version_compare(phpversion(), ADD_MIN_PHP_VERSION) === -1) {
die("ADD MVC Error: PHP version must be at least " . ADD_MIN_PHP_VERSION . " or higher!");
}
if (!isset($C)) {
$C = new STDClass();
}
# Sets the add_dir if not set. And it may be smart not to let the user(developer) set this on the first place
if (empty($C->add_dir)) {
$C->add_dir = realpath(dirname(__FILE__));
}
require $C->add_dir . '/classes/add.class.php';
$GLOBALS[add::CONFIG_VARNAME] = add::config($C);
if (php_sapi_name() == "cli") {
add::content_type('text/plain');
}
# Set the handlers
spl_autoload_register('add::load_class');
set_exception_handler('add::handle_exception');
set_error_handler('add::handle_error');
register_shutdown_function('add::handle_shutdown');
# Set the includes dir
if (!isset($C->incs_dir)) {
$C->incs_dir = $C->root_dir . '/includes';
}
# Merge config declared class directories
$C->classes_dirs = array_merge(array($C->incs_dir . '/classes'), isset($C->classes_dirs) ? is_array($C->classes_dirs) ? $C->classes_dirs : (array) $C->classes_dirs : array(), array($C->add_dir . '/classes'));
# Set these rarely used directory variables
if (!isset($C->configs_dir)) {
$C->configs_dir = $C->incs_dir . '/configs';
示例6: us_diff_html
/**
* Microseconds diff html style
*
* @since ADD MVC 0.4
*/
public static function us_diff_html($string, $second_difference)
{
if (add::content_type() == 'text/plain') {
return "{$string}";
}
$styles_array = array();
if ($second_difference > 1) {
$styles_array[] = 'color:red';
if ($second_difference > 10) {
$styles_array[] = 'font-weight:bold';
}
} else {
if ($second_difference < 1) {
$styles_array[] = 'color:green';
}
}
$styles = implode(';', $styles_array);
return "<span style='{$styles}'>{$string}</span>";
}
示例7: handle_exception
/**
* handle_exception()
* The error handler for exceptions
* @param Exception $e the exception to handle
* @since ADD MVC 0.0
*/
static function handle_exception(Exception $e)
{
try {
try {
if (method_exists($e, 'handle_exception')) {
return $e->handle_exception();
} else {
throw new Exception("Non e_add exception sub class or no handle_exception() function found for exception");
}
} catch (Exception $e2) {
while (ob_get_level()) {
ob_end_clean();
}
if ($e instanceof SmartyException) {
static::handle_exception(new e_smarty($e->getMessage(), $e));
}
if (add::content_type() == 'text/plain') {
die(get_class($e) . "(#" . $e->getCode() . ")\r\n\r\n" . $e->getMessage() . "\r\n\r\n" . $e->getFile() . ":" . $e->getLine() . "\r\n\r\n\r\n\r\n");
} else {
DEFINE('add\\terminal_error\\error_message', $e->getMessage());
DEFINE('add\\terminal_error\\error_header', get_class($e));
DEFINE('add\\terminal_error\\error_footer', $e->getFile() . ":" . $e->getLine());
if (!headers_sent() && !add::include_include_file('terminal_error.php')) {
throw new Exception("Failed to display terminal error");
}
add::shutdown(false);
}
}
} catch (Exception $e3) {
$e1_string = "<div style='color:red'>" . get_class($e) . "(#" . $e->getCode() . ")" . $e->getMessage() . "\r\n" . $e->getFile() . ":" . $e->getLine() . "</div>";
echo $e1_string;
$e3_string = "<div style='color:red'>" . get_class($e3) . "(#" . $e3->getCode() . ")" . $e3->getMessage() . "\r\n" . $e3->getFile() . ":" . $e3->getLine() . "</div>";
if ($e3_string != $e1_string) {
echo $e3_string;
}
debug::var_dump($e3->getTraceAsString());
die;
}
}
示例8: handle_exception
/**
* handle_exception()
* The error handler for exceptions
* @param Exception $e the exception to handle
* @since ADD MVC 0.0
*/
static function handle_exception(Exception $e)
{
try {
if (method_exists($e, 'handle_exception')) {
return $e->handle_exception();
} else {
while (ob_get_level()) {
ob_end_clean();
}
if ($e instanceof SmartyException) {
static::handle_exception(new e_smarty($e->getMessage(), $e));
}
if (add::content_type() == 'text/plain') {
die(get_class($e) . "(#" . $e->getCode() . ")\r\n\r\n" . $e->getMessage() . "\r\n\r\n" . $e->getFile() . ":" . $e->getLine() . "\r\n\r\n\r\n\r\n");
} else {
DEFINE('add\\terminal_error\\error_message', $e->getMessage());
DEFINE('add\\terminal_error\\error_header', get_class($e));
DEFINE('add\\terminal_error\\error_footer', $e->getFile() . ":" . $e->getLine());
if (!headers_sent() && !add::include_include_file('terminal_error.php')) {
throw new $e();
}
add::shutdown(false);
}
}
} catch (Exception $e) {
die("<div style='color:red'>" . $e->getMessage() . "\r\n" . $e->getFile() . ":" . $e->getLine() . "</div>");
}
}