本文整理汇总了PHP中ob_get_contents函数的典型用法代码示例。如果您正苦于以下问题:PHP ob_get_contents函数的具体用法?PHP ob_get_contents怎么用?PHP ob_get_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ob_get_contents函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: command_dd
function command_dd()
{
$args = func_get_args();
$options = $this->get_options();
$dd = kernel::single('dev_docbuilder_dd');
if (empty($args)) {
$dd->export();
} else {
foreach ($args as $app_id) {
$dd->export_tables($app_id);
}
}
if ($filename = $options['result-file']) {
ob_start();
$dd->output();
$out = ob_get_contents();
ob_end_clean();
if (!is_dir(dirname($filename))) {
throw new Exception('cannot find the ' . dirname($filename) . 'directory');
} elseif (is_dir($filename)) {
throw new Exception('the result-file path is a directory.');
}
file_put_contents($options['result-file'], $out);
echo 'data dictionary doc export success.';
} else {
$dd->output();
}
}
示例2: smarty_core_display_debug_console
/**
* Smarty debug_console function plugin
*
* Type: core<br>
* Name: display_debug_console<br>
* Purpose: display the javascript debug console window
* @param array Format: null
* @param Smarty
*/
function smarty_core_display_debug_console($params, &$smarty)
{
// we must force compile the debug template in case the environment
// changed between separate applications.
if (empty($smarty->debug_tpl)) {
// set path to debug template from SMARTY_DIR
$smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
if ($smarty->security && is_file($smarty->debug_tpl)) {
$smarty->secure_dir[] = realpath($smarty->debug_tpl);
}
$smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl';
}
$_ldelim_orig = $smarty->left_delimiter;
$_rdelim_orig = $smarty->right_delimiter;
$smarty->left_delimiter = '{';
$smarty->right_delimiter = '}';
$_compile_id_orig = $smarty->_compile_id;
$smarty->_compile_id = null;
$_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path)) {
ob_start();
$smarty->_include($_compile_path);
$_results = ob_get_contents();
ob_end_clean();
} else {
$_results = '';
}
$smarty->_compile_id = $_compile_id_orig;
$smarty->left_delimiter = $_ldelim_orig;
$smarty->right_delimiter = $_rdelim_orig;
return $_results;
}
示例3: popular
function popular($skin_dir = 'basic', $pop_cnt = 7, $date_cnt = 3)
{
global $config, $g5;
if (!$skin_dir) {
$skin_dir = 'basic';
}
$date_gap = date("Y-m-d", G5_SERVER_TIME - $date_cnt * 86400);
$sql = " select pp_word, count(*) as cnt from {$g5['popular_table']} where pp_date between '{$date_gap}' and '" . G5_TIME_YMD . "' group by pp_word order by cnt desc, pp_word limit 0, {$pop_cnt} ";
$result = sql_query($sql);
for ($i = 0; $row = sql_fetch_array($result); $i++) {
$list[$i] = $row;
// 스크립트등의 실행금지
$list[$i]['pp_word'] = get_text($list[$i]['pp_word']);
}
ob_start();
if (G5_IS_MOBILE) {
$popular_skin_path = G5_MOBILE_PATH . '/' . G5_SKIN_DIR . '/popular/' . $skin_dir;
$popular_skin_url = G5_MOBILE_URL . '/' . G5_SKIN_DIR . '/popular/' . $skin_dir;
} else {
$popular_skin_path = G5_SKIN_PATH . '/popular/' . $skin_dir;
$popular_skin_url = G5_SKIN_URL . '/popular/' . $skin_dir;
}
include_once $popular_skin_path . '/popular.skin.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
}
示例4: render
public function render($template = null, array $arguments = null)
{
if (null === $template) {
return false;
}
$parentTemplate = $this->currentTemplate;
$this->currentTemplate = $this->totalTemplates = $this->totalTemplates + 1;
$path = $this->finder->getPath($template);
if (!is_file($path)) {
throw new \RuntimeException('The requested view file doesn\'t exist in: <strong>' . $path . '</strong>', 404);
}
ob_start();
try {
$this->requireInContext($path, $arguments);
} catch (\Exception $e) {
ob_end_clean();
throw $e;
}
if (isset($this->parent[$this->currentTemplate])) {
$this->data['content'] = ob_get_contents();
ob_end_clean();
$this->render($this->parent[$this->currentTemplate], $arguments);
} else {
ob_end_flush();
}
if ($parentTemplate == 0) {
$this->clean();
} else {
$this->currentTemplate = $parentTemplate;
}
}
示例5: template
function template($filename, $flag = TEMPLATE_DISPLAY)
{
global $_W;
$source = IA_ROOT . "/web/themes/{$_W['template']}/{$filename}.html";
$compile = IA_ROOT . "/data/tpl/web/{$_W['template']}/{$filename}.tpl.php";
if (!is_file($source)) {
$source = IA_ROOT . "/web/themes/default/{$filename}.html";
$compile = IA_ROOT . "/data/tpl/web/default/{$filename}.tpl.php";
}
if (!is_file($source)) {
exit("Error: template source '{$filename}' is not exist!");
}
if (DEVELOPMENT || !is_file($compile) || filemtime($source) > filemtime($compile)) {
template_compile($source, $compile);
}
switch ($flag) {
case TEMPLATE_DISPLAY:
default:
extract($GLOBALS, EXTR_SKIP);
include $compile;
break;
case TEMPLATE_FETCH:
extract($GLOBALS, EXTR_SKIP);
ob_clean();
ob_start();
include $compile;
$contents = ob_get_contents();
ob_clean();
return $contents;
break;
case TEMPLATE_INCLUDEPATH:
return $compile;
break;
}
}
示例6: pc_tag
/**
* PC标签中调用数据
* @param array $data 配置数据
*/
public function pc_tag($data)
{
$siteid = isset($data['siteid']) && intval($data['siteid']) ? intval($data['siteid']) : get_siteid();
$r = $this->db->select(array('pos' => $data['pos'], 'siteid' => $siteid));
$str = '';
if (!empty($r) && is_array($r)) {
foreach ($r as $v) {
if (defined('IN_ADMIN') && !defined('HTML')) {
$str .= '<div id="block_id_' . $v['id'] . '" class="admin_block" blockid="' . $v['id'] . '">';
}
if ($v['type'] == '2') {
extract($v, EXTR_OVERWRITE);
$data = string2array($data);
if (!defined('HTML')) {
ob_start();
include $this->template_url($id);
$str .= ob_get_contents();
ob_clean();
} else {
include $this->template_url($id);
}
} else {
$str .= $v['data'];
}
if (defined('IN_ADMIN') && !defined('HTML')) {
$str .= '</div>';
}
}
}
return $str;
}
示例7: ckeditor_parse_php_info
/**
* http://www.php.net/manual/en/function.phpinfo.php
* code at adspeed dot com
* 09-Dec-2005 11:31
* This function parses the phpinfo output to get details about a PHP module.
*/
function ckeditor_parse_php_info()
{
ob_start();
phpinfo(INFO_MODULES);
$s = ob_get_contents();
ob_end_clean();
$s = strip_tags($s, '<h2><th><td>');
$s = preg_replace('/<th[^>]*>([^<]+)<\\/th>/', "<info>\\1</info>", $s);
$s = preg_replace('/<td[^>]*>([^<]+)<\\/td>/', "<info>\\1</info>", $s);
$vTmp = preg_split('/(<h2>[^<]+<\\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE);
$vModules = array();
for ($i = 1; $i < count($vTmp); $i++) {
if (preg_match('/<h2>([^<]+)<\\/h2>/', $vTmp[$i], $vMat)) {
$vName = trim($vMat[1]);
$vTmp2 = explode("\n", $vTmp[$i + 1]);
foreach ($vTmp2 as $vOne) {
$vPat = '<info>([^<]+)<\\/info>';
$vPat3 = "/{$vPat}\\s*{$vPat}\\s*{$vPat}/";
$vPat2 = "/{$vPat}\\s*{$vPat}/";
if (preg_match($vPat3, $vOne, $vMat)) {
// 3cols
$vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]), trim($vMat[3]));
} elseif (preg_match($vPat2, $vOne, $vMat)) {
// 2cols
$vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
}
}
}
}
return $vModules;
}
示例8: Explain
function Explain($sql, $partial = false)
{
$save = $this->conn->LogSQL(false);
if ($partial) {
$sqlq = $this->conn->qstr($sql . '%');
$arr = $this->conn->GetArray("select distinct sql1 from adodb_logsql where sql1 like {$sqlq}");
if ($arr) {
foreach ($arr as $row) {
$sql = reset($row);
if (crc32($sql) == $partial) {
break;
}
}
}
}
$qno = rand();
$ok = $this->conn->Execute("EXPLAIN PLAN SET QUERYNO={$qno} FOR {$sql}");
ob_start();
if (!$ok) {
echo "<p>Have EXPLAIN tables been created?</p>";
} else {
$rs = $this->conn->Execute("select * from explain_statement where queryno={$qno}");
if ($rs) {
rs2html($rs);
}
}
$s = ob_get_contents();
ob_end_clean();
$this->conn->LogSQL($save);
$s .= $this->Tracer($sql);
return $s;
}
示例9: usage
function usage()
{
ob_start();
?>
This plug-in is designed to help you create input buttons which perform an action 'onClick'. The plug-in also can also optionally add a 'class' to the input button.
BASIC USAGE:
{exp:np_jsbutton value="Cancel" onclick='history.go(-1);'}
PARAMETERS:
value = 'Cancel' (no default - must be specified)
- The input button text.
onclick = 'some javascript' (no default - must be specified)
- The javascript that you want to execute on click.
RELEASE NOTES:
1.0 - Initial Release.
For updates and support check the developers website: http://nathanpitman.com/
<?php
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
示例10: getcontacts
function getcontacts($user, $password, &$result)
{
if (!$this->checklogin($user, $password)) {
return 0;
}
$cookies = array();
$bRet = $this->readcookies(COOKIEJAR, $cookies);
if (!$bRet && !$cookies['JSESSIONID']) {
return 0;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);
curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
curl_setopt($ch, CURLOPT_URL, "http://www51.mail.sohu.com/webapp/contact");
ob_start();
curl_exec($ch);
$content = ob_get_contents();
ob_end_clean();
curl_close($ch);
$bRet = $this->_parsedata($content, $result);
if (!$bRet) {
return 0;
}
return 1;
}
示例11: b_wp_archives_monthly_show
function b_wp_archives_monthly_show($options, $wp_num = "")
{
$block_style = $options[0] ? $options[0] : 0;
$with_count = $options[1] == 0 ? false : true;
global $wpdb, $siteurl, $wp_id, $wp_inblock, $use_cache;
$id = 1;
$use_cache = 1;
if ($wp_num == "") {
$wp_id = $wp_num;
$wp_inblock = 1;
require dirname(__FILE__) . '/../wp-config.php';
$wp_inblock = 0;
}
ob_start();
if ($block_style == 0) {
// Simple Listing
get_archives('monthly', '', 'html', '', '', $with_count);
} else {
// Dropdown Listing
echo '<form name="archiveform' . $wp_num . '" action="">';
echo '<select name="archive_chrono" onchange="window.location = (document.forms.archiveform' . $wp_num . '.archive_chrono[document.forms.archiveform' . $wp_num . '.archive_chrono.selectedIndex].value);"> ';
echo '<option value="">' . _WP_BY_MONTHLY . '</option>';
get_archives('monthly', '', 'option', '', '', $with_count);
echo '</select>';
echo '</form>';
}
$block['content'] = ob_get_contents();
ob_end_clean();
return $block;
}
示例12: tc_post_content
/**
* The default template for displaying single post content
*
* @package Customizr
* @since Customizr 3.0
*/
function tc_post_content()
{
//check conditional tags : we want to show single post or single custom post types
global $post;
$tc_show_single_post_content = isset($post) && 'page' != $post->post_type && 'attachment' != $post->post_type && is_singular() && !tc__f('__is_home_empty');
if (!apply_filters('tc_show_single_post_content', $tc_show_single_post_content)) {
return;
}
//display an icon for div if there is no title
$icon_class = in_array(get_post_format(), array('quote', 'aside', 'status', 'link')) ? apply_filters('tc_post_format_icon', 'format-icon') : '';
ob_start();
do_action('__before_content');
?>
<section class="entry-content <?php
echo $icon_class;
?>
">
<?php
the_content(__('Continue reading <span class="meta-nav">→</span>', 'customizr'));
?>
<?php
wp_link_pages(array('before' => '<div class="pagination pagination-centered">' . __('Pages:', 'customizr'), 'after' => '</div>'));
?>
</section><!-- .entry-content -->
<?php
do_action('__after_content');
$html = ob_get_contents();
if ($html) {
ob_end_clean();
}
echo apply_filters('tc_post_content', $html);
}
示例13: fetch
public function fetch($name, $type = NULL)
{
if ($type == "element") {
$path = Absolute_Path . APPDIR . DIRSEP . "views" . DIRSEP . "elements" . DIRSEP . $name . ".php";
$errorMsg = "The <strong>element</strong> '<em>" . $name . "</em>' does not exist.";
} elseif ($type == "layout") {
$path = Absolute_Path . APPDIR . DIRSEP . "views" . DIRSEP . "layouts" . DIRSEP . $this->layout . ".php";
$errorMsg = "The <strong>layout</strong> '<em>" . $this->layout . "</em>' does not exist.";
} else {
$route = explode(".", $name);
$path = Absolute_Path . APPDIR . DIRSEP . "views" . DIRSEP . $route[0] . DIRSEP . $route[1] . ".php";
$errorMsg = "The <strong>view</strong> '<em>" . $name . "</em>' does not exist.";
}
if (file_exists($path) == false) {
throw new Exception("FlavorPHP error: " . $errorMsg);
return false;
}
foreach ($this->vars as $key => $value) {
${$key} = $value;
}
ob_start();
include $path;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
示例14: buildContent
/**
* Build the content for this action
*
* @return boolean
* @access public
* @since 4/26/05
*/
function buildContent()
{
$actionRows = $this->getActionRows();
$harmoni = Harmoni::instance();
ob_start();
CollectionsPrinter::printFunctionLinks();
$layout = new Block(ob_get_contents(), STANDARD_BLOCK);
ob_end_clean();
$actionRows->add($layout, null, null, CENTER, CENTER);
$type = HarmoniType::fromString(urldecode(RequestContext::value('type')));
$repositoryManager = Services::getService("Repository");
// Get the Repositories
$allRepositories = $repositoryManager->getRepositoriesByType($type);
// put the repositories into an array and order them.
// @todo, do authorization checking
$repositoryArray = array();
while ($allRepositories->hasNext()) {
$repository = $allRepositories->next();
$repositoryArray[$repository->getDisplayName()] = $repository;
}
ksort($repositoryArray);
// print the Results
$resultPrinter = new ArrayResultPrinter($repositoryArray, 2, 20, "printrepositoryShort", $harmoni);
$resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
$resultLayout = $resultPrinter->getLayout();
$actionRows->add($resultLayout, null, null, CENTER, CENTER);
}
示例15: _from_unicode
/**
* UTF8::from_unicode
*
* @package JsonApiApplication
* @author JsonApiApplication Team
* @copyright (c) 2007-2012 JsonApiApplication Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _from_unicode($arr)
{
ob_start();
$keys = array_keys($arr);
foreach ($keys as $k) {
// ASCII range (including control chars)
if ($arr[$k] >= 0 and $arr[$k] <= 0x7f) {
echo chr($arr[$k]);
} elseif ($arr[$k] <= 0x7ff) {
echo chr(0xc0 | $arr[$k] >> 6);
echo chr(0x80 | $arr[$k] & 0x3f);
} elseif ($arr[$k] == 0xfeff) {
// nop -- zap the BOM
} elseif ($arr[$k] >= 0xd800 and $arr[$k] <= 0xdfff) {
// Found a surrogate
throw new UTF8_Exception("UTF8::from_unicode: Illegal surrogate at index: ':index', value: ':value'", array(':index' => $k, ':value' => $arr[$k]));
} elseif ($arr[$k] <= 0xffff) {
echo chr(0xe0 | $arr[$k] >> 12);
echo chr(0x80 | $arr[$k] >> 6 & 0x3f);
echo chr(0x80 | $arr[$k] & 0x3f);
} elseif ($arr[$k] <= 0x10ffff) {
echo chr(0xf0 | $arr[$k] >> 18);
echo chr(0x80 | $arr[$k] >> 12 & 0x3f);
echo chr(0x80 | $arr[$k] >> 6 & 0x3f);
echo chr(0x80 | $arr[$k] & 0x3f);
} else {
throw new UTF8_Exception("UTF8::from_unicode: Codepoint out of Unicode range at index: ':index', value: ':value'", array(':index' => $k, ':value' => $arr[$k]));
}
}
$result = ob_get_contents();
ob_end_clean();
return $result;
}