本文整理汇总了PHP中highlight_file函数的典型用法代码示例。如果您正苦于以下问题:PHP highlight_file函数的具体用法?PHP highlight_file怎么用?PHP highlight_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了highlight_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: db
public function db()
{
//将MongoModel放入项目Lib\Model下并建一个测试的TestModel
//将驱动放入核心的Lib\Driver\Db\下
$mongo = D('Test');
//显示表名
$this->assign('table_name', $mongo->getTableName());
//清除所有数据
$map = array();
$map['where'] = '1=1';
$result = $mongo->delete($map);
if ($result) {
$this->assign('clear', 1);
}
//添加数据
$data = array('title' => 'test', 'id' => '1');
$mongo->add($data);
$data['id'] = '2';
$mongo->add($data);
$add = $mongo->select();
$this->assign('add', $add);
//更新id为1的记录的title字段值设为title2
$mongo->where(array('id' => '1'))->save(array('title' => 'title2'));
$update = $mongo->select();
$this->assign('update', $update);
$action_code = highlight_file(__FILE__, 1);
$this->assign('action_code', $action_code);
$this->display();
}
示例2: tablesrc
function tablesrc()
{
header('Content-type: text/html;charset=utf8');
$file = APP_DIR . '/' . $_GET['tableapp'] . '/dbschema/' . $_GET['tablename'] . '.php';
echo '<div style="padding:2px 10px;border-bottom:1px solid #ccc">' . $file . '</div>';
highlight_file($file);
}
示例3: file
/**
* Preview code from a PHP file
*
* @param string $file file path
* @param int|null $activeLine active line number
* @param int|null $lineRange range of lines to render (around active line)
* @param string $className wrapper class name
* @return string|null
*/
public static function file($file, $activeLine = null, $lineRange = null, $className = 'code-preview')
{
$highlighted = @highlight_file($file, true);
if (false !== $highlighted) {
return self::render($highlighted, $activeLine, $lineRange, $className);
}
}
示例4: indexAction
/**
* Index
*
* @return void
*/
public function indexAction()
{
$this->view->navSetup = highlight_file('App/Demo/Navigation.setup.php', true);
$this->view->navSetup = str_replace('Zym_Navigation_Demo',
'Zym_Navigation',
$this->view->navSetup);
}
示例5: indexAction
public function indexAction()
{
//如果邮件不能正常发送,请根据错误提示寻找原因
//常见的问题就是没有开启IMAP/SMTP服务
$time = microtime(1);
$host = 'smtp.qq.com';
$pors = 25;
$user = 'QQ邮箱';
$pass = '密码';
$smtp = new emailModel($host, $pors, $user, $pass);
$to = '接收邮箱';
$from = $user;
$subject = 'PHP邮件测试' . $time;
//邮件主题
$body = '测试成功';
//邮件内容
//定义如下两项后,发件人内容显示类似:PHP邮件测试<QQ邮箱>
$from_email = $user;
$from_name = 'PHP邮件测试';
if ($smtp->send($to, $from, $subject, $body, $from_email, $from_name)) {
echo '总耗时:', microtime(1) - $time;
}
echo '<h1>控制器源代码:</h1><hr />';
highlight_file(__FILE__);
}
示例6: indexAction
public function indexAction()
{
//调试状态关闭缓存功能,默认为调试状态。0:非调试状态 1:调试状态
//在初始化mPHP前,可以通过配置$GLOBALS['CFG']['debug']来设定
//初始化mPHP后,可以通过配置mPHP::$debug来设定
mPHP::$debug = 0;
//初始化阶段mPHP已经声明了视图类
//mPHP::$view = new view();
$view = mPHP::$view;
$tpl = 'view';
//模版名称
$file = CACHE_PATH . "html/{$tpl}.html";
//缓存html文件保存位置
$time = 5;
//缓存时间(秒)
$cache = $view->cache($file, $time);
if ($cache) {
return true;
}
//缓存有效期内直接返回
sleep(1);
//模拟耗时操作
$view->data['title'] = 'mPHP视图类缓存demo ';
$view->data['h'] = 'hello ';
$view->data['w'] = 'world ';
$view->loadTpl($tpl);
//加载模版
highlight_file(__FILE__);
}
示例7: stedisplayFileInHTML
/**
* SmartTemplate Extension config
* Print Content of Configuration Parameters
*
* Usage Example:
* Content: $_CONFIG['webmaster'] = 'philipp@criegern.com';
* Template: Please Contact Webmaster: {config:"webmaster"}
* Result: Please Contact Webmaster: philipp@criegern.com
*
* @author Philipp v. Criegern philipp@criegern.com
*/
function stedisplayFileInHTML($directory, $file)
{
if (file_exists($directory . "/" . $file)) {
return highlight_file($directory . "/" . $file, 1);
} else {
return "File does not exist {$directory}, {$file}";
}
}
示例8: showSource
function showSource($dir, $file)
{
$path = $dir . $file;
echo '<div>';
echo '<h1>' . $path . '</h1>';
highlight_file($path);
echo '</div>' . "\n";
}
示例9: handle
public function handle()
{
$types = array("php" => "text/html", "html" => "text/html", "htm" => "text/html", "css" => "text/css", "jpg" => "image/jpeg", "jpeg" => "image/jpeg", "gif" => "image/gif", "phps" => "text/html", "pdf" => "application/pdf", "" => "text/plain");
$real_file = $this->options["rewrite"] ? $this->applyRewriteRules() : $this->request->path . "/" . $this->request->file;
$extension = array_pop(explode(".", basename($real_file)));
if (!in_array($extension, array_keys($types))) {
$extension = "";
}
if (file_exists($this->request->document_root . $real_file)) {
// DefaultHandler: File exists
if ($extension == "phps") {
$output = highlight_file($this->request->document_root . $real_file, true);
$headers = array("Content-Type" => $types[$extension], "Content-Length" => strlen($output));
$response = new Zend_Http_Response(200, $headers, $output);
} else {
if ($extension == "php") {
// DefaultHandler: PHP script
$current_directory = getcwd();
chdir(dirname($this->request->document_root . $real_file));
// Setting up globals
$_GET = $this->request->get;
$_POST = $this->request->post;
$_REQUEST = array_merge($_GET, $_POST);
$_SERVER["DOCUMENT_ROOT"] = $this->request->document_root;
$_SERVER["SCRIPT_FILENAME"] = $this->request->file;
$_SERVER["PHP_SELF"] = $this->request->path;
$_SERVER["SCRIPT_NAME"] = $this->request->path . "/" . $this->request->file;
$_SERVER["argv"] = $this->request->query_string;
$_SERVER["SERVER_ADDR"] = "";
$_SERVER["SERVER_NAME"] = "";
$_SERVER["SERVER_SOFTWARE"] = "Zend HTTP Server (alpha)";
$_SERVER["SERVER_PROTOCOL"] = "";
$_SERVER["REQUEST_METHOD"] = $this->request->method;
$_SERVER["REQUEST_TIME"] = time();
$_SERVER["QUERY_STRING"] = $this->request->query_string;
$_SERVER["REQUEST_URI"] = $this->request->uri;
$_SERVER["HTTP_HOST"] = $this->request->headers["Host"];
unset($_SERVER["argc"]);
$output = self::startScript($this->request->document_root . $real_file);
// DefaultHandler: Done. Sending response.
chdir($current_directory);
$headers = array("Content-Type" => "text/html", "Content-Length" => strlen($output));
foreach (headers_list() as $header) {
list($name, $value) = split(":", $header);
$headers[$name] = $value;
}
$response = new Zend_Http_Response(200, $headers, $output);
} else {
$data = file_get_contents($this->request->document_root . $real_file);
$response = new Zend_Http_Response(200, array("Content-Type" => $types[$extension], "Content-Length" => strlen($data)), $data);
}
}
} else {
$response = new Zend_Http_Response(404, array("Content-Type" => "text/plain"), "File Not Found!");
}
return $response;
}
示例10: highlight
/**
* Highlighter with built-in check for list of disabled function (Google AppEngine)
*
* @param string $file Name of the file
*/
public static function highlight($file)
{
$highlightFileFunc = new \ReflectionFunction('highlight_file');
if (!$highlightFileFunc->isDisabled()) {
highlight_file($file);
} else {
echo '<pre>' . htmlspecialchars(file_get_contents($file)) . '</pre>';
}
}
示例11: dumpFile
/**
* Output a dump of a file
*
* @param mixed $file file to dump
* @param bool $echo true to echo dump, false to return dump as string
*
* @return string
*/
public static function dumpFile($file, $echo = true)
{
$msg = highlight_file($file, true);
$msg = "<div style='padding: 5px; font-weight: bold'>{$msg}</div>";
if ($echo) {
echo $msg;
}
return $msg;
}
示例12: body
/**
* Displays PHP code from selected file with syntax highlighting.
*
* @param string filename
*/
public function body($arg)
{
print '<div align="left">';
if (file_exists($arg)) {
highlight_file($arg);
} else {
echo "File {$arg} does not exist.";
}
print '</div>';
}
示例13: onView
public function onView($param)
{
$class = $param['source'];
$file = "App/Control/{$class}.php";
if (file_exists($file)) {
$panel = new Panel('Código-fonte: ' . $class);
$panel->add(highlight_file($file, TRUE));
parent::add($panel);
}
}
示例14: tnvExample_Change
protected function tnvExample_Change($strFormId, $strControlId, $strParameter)
{
$objItem = $this->tnvExample->SelectedItem;
if (is_dir($this->tnvExample->SelectedValue)) {
$this->pnlCode->Text = 'Current directory is <b>' . $this->tnvExample->SelectedItem->Name . '</b>. ' . 'Please select a file on the left';
} else {
$strCode = highlight_file($this->tnvExample->SelectedValue, true);
$this->pnlCode->Text = $strCode;
}
}
示例15: ViewSource
public static function ViewSource()
{
echo '<h1>You are looking at the output from MyClass::ViewSource</h1>
<ul>
<li><a href="/simple-site">Call MyClass::MyMethod</a></li>
<li><a href="/simple-site/sample">Call MyClass::MyOtherMethod</a></li>
<li><a href="/simple-site/somepath/source">View the source of this page</a></li>
</ul>';
highlight_file(__FILE__);
}