本文整理汇总了PHP中Q::textMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Q::textMode方法的具体用法?PHP Q::textMode怎么用?PHP Q::textMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q
的用法示例。
在下文中一共展示了Q::textMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Q_exception_native
function Q_exception_native($params)
{
extract($params);
/**
* @var Exception $exception
*/
if ($is_ajax = Q_Request::isAjax()) {
$json = @Q::json_encode(array('errors' => Q_Exception::toArray(array($exception))));
$callback = Q_Request::callback();
switch (strtolower($is_ajax)) {
case 'iframe':
// Render an HTML layout for ajax
if (!Q_Response::$batch) {
header("Content-type: text/html");
}
echo <<<EOT
<!doctype html><html lang=en>
<head><meta charset=utf-8><title>Q Result</title></head>
<body>
<script type="text/javascript">
window.result = function () { return {$json} };
</script>
</body>
</html>
EOT;
break;
case 'json':
// Render a JSON layout for ajax
// Render a JSON layout for ajax
default:
header("Content-type: " . ($callback ? "application/javascript" : "application/json"));
echo $callback ? "{$callback}({$json})" : $json;
}
} else {
if (Q::textMode()) {
echo Q_Exception::coloredString($exception);
exit;
}
$message = $exception->getMessage();
$file = $exception->getFile();
$line = $exception->getLine();
if (is_callable(array($exception, 'getTraceAsStringEx'))) {
$trace_string = $exception->getTraceAsStringEx();
} else {
$trace_string = $exception->getTraceAsString();
}
if ($exception instanceof Q_Exception_PhpError or !empty($exception->messageIsHtml)) {
// do not sanitize $message
} else {
$message = Q_Html::text($message);
}
$content = "<h1 class='exception_message'>{$message}</h1>";
if (Q_Config::get('Q', 'exception', 'showFileAndLine', true)) {
$content .= "<h3 class='exception_fileAndLine'>in {$file} ({$line})</h3>";
}
if (Q_Config::get('Q', 'exception', 'showTrace', true)) {
$content .= "<pre class='exception_trace'>{$trace_string}</pre>";
}
$content .= str_repeat(' ', 512);
// because of chrome
$title = "Exception occurred";
$dashboard = "";
echo Q::view('Q/layout/html.php', compact('content', 'dashboard', 'title'));
}
$app = Q_Config::get('Q', 'app', null);
$colored = Q_Exception::coloredString($exception);
Q::log("{$app}: Exception in " . ceil(Q::milliseconds()) . "ms:\n\n{$colored}\n", null, true, array('maxLength' => 10000));
}
示例2: var_dump
/**
* Dumps a variable.
* Note: cannot show protected or private members of classes.
* @method var_dump
* @static
* @param {mixed} $var
* the variable to dump
* @param {integer} $max_levels=null
* the maximum number of levels to recurse
* @param {string} $label='$'
* optional - label of the dumped variable. Defaults to $.
* @param {boolean} $return_content=null
* if true, returns the content instead of dumping it.
* You can also set to "text" to return text instead of HTML
* @return {string|null}
*/
static function var_dump($var, $max_levels = null, $label = '$', $return_content = null)
{
$scope = false;
$prefix = 'unique';
$suffix = 'value';
$as_text = $return_content === 'text' ? true : Q::textMode();
if ($scope) {
$vals = $scope;
} else {
$vals = $GLOBALS;
}
$old = $var;
$var = $new = $prefix . rand() . $suffix;
$vname = FALSE;
foreach ($vals as $key => $val) {
if ($val === $new) {
// ingenious way of finding a global var :)
$vname = $key;
}
}
$var = $old;
if ($return_content) {
ob_start();
}
if ($as_text) {
echo PHP_EOL;
} else {
echo "<pre style='margin: 0px 0px 10px 0px; display: block; background: white; color: black; font-family: Verdana; border: 1px solid #cccccc; padding: 5px; font-size: 10px; line-height: 13px;'>";
}
if (!isset(self::$var_dump_max_levels)) {
self::$var_dump_max_levels = Q_Config::get('Q', 'var_dump_max_levels', 5);
}
$current_levels = self::$var_dump_max_levels;
if (isset($max_levels)) {
self::$var_dump_max_levels = $max_levels;
}
self::do_dump($var, $label . $vname, null, null, $as_text);
if (isset($max_levels)) {
self::$var_dump_max_levels = $current_levels;
}
if ($as_text) {
echo PHP_EOL;
} else {
echo "</pre>";
}
if ($return_content) {
return ob_get_clean();
}
return null;
}