本文整理汇总了PHP中get_defined_constants函数的典型用法代码示例。如果您正苦于以下问题:PHP get_defined_constants函数的具体用法?PHP get_defined_constants怎么用?PHP get_defined_constants使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_defined_constants函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sendMail
function sendMail($params)
{
// Cargar todas las constantes definidas
$constants = get_defined_constants();
// Obtener la direccion a la cual se va a enviar (TO)
$to = $params['to'];
// Obtener la direccion a la cual se va a enviar (CC)
$cc = $params['cc'];
// Obtener la direccion a la cual se va a enviar (BCC)
$bcc = $params['bcc'];
// Obtener el subject del mail
$subject = $params['subject'];
// Obtener el path del template
$template = $constants[strtoupper($params['TEMPLATE'])];
// Cargar parametros del mail
$mail = new Mail();
$mail->from = MAIL_FROM;
$mail->to = $to;
$mail->cc = $cc;
$mail->bcc = $bcc;
$mail->subject = $subject;
$mail->body = MailHelper::_getBody($template, $params);
// Si el cuerpo excede cierta cantidad de caracteres, se codifica
// en base64
$mail->base64 = strlen($mail->body) > CANT_CARACTERES_EMAIL;
// Enviar mail
return $mail->send();
}
开发者ID:Nilphy,项目名称:moteguardian,代码行数:28,代码来源:clase.MailHelper.php
示例2: query
function query($path, $content = array(), $method = 'GET')
{
@ini_set('track_errors', 1);
// @ - may be disabled
$file = @file_get_contents($this->_url . ($this->_db != "" ? "{$this->_db}/" : "") . $path, false, stream_context_create(array('http' => array('method' => $method, 'content' => json_encode($content), 'ignore_errors' => 1))));
if (!$file) {
$this->error = $php_errormsg;
return $file;
}
if (!preg_match('~^HTTP/[0-9.]+ 2~i', $http_response_header[0])) {
$this->error = $file;
return false;
}
$return = json_decode($file, true);
if (!$return) {
$this->errno = json_last_error();
if (function_exists('json_last_error_msg')) {
$this->error = json_last_error_msg();
} else {
$constants = get_defined_constants(true);
foreach ($constants['json'] as $name => $value) {
if ($value == $this->errno && preg_match('~^JSON_ERROR_~', $name)) {
$this->error = $name;
break;
}
}
}
}
return $return;
}
开发者ID:amit0773,项目名称:manaslake,代码行数:30,代码来源:elastic.inc.php
示例3: __construct
public function __construct()
{
parent::__construct("lint-const-literals", "Lint (use of lower- or mixed-case string literals)");
foreach (get_defined_constants() as $const_name => $value) {
$this->system_constants[$const_name] = true;
}
}
开发者ID:gariev,项目名称:xref,代码行数:7,代码来源:LowerCaseLiterals.class.php
示例4: load
static function load($file, $return = false)
{
if (file_exists($file)) {
$before = get_defined_constants();
// 数组返回值方式定义
$lang = (include $file);
if (!is_array($lang)) {
if (isset($_lang)) {
// 采用 $_lang['aaa']= value 方式
$lang =& $_lang;
} else {
// 采用define('aaa',value) 方式
$after = get_defined_constants();
$define = array_diff_assoc($after, $before);
$lang = $define;
}
}
self::$_lang = array_merge(self::$_lang, array_change_key_case($lang));
unset($lang);
if ($return) {
return self::$_lang;
}
} else {
return false;
}
}
开发者ID:BGCX262,项目名称:zxzjob-svn-to-git,代码行数:26,代码来源:Language.class.php
示例5: osc_theme_toggle
function osc_theme_toggle($params, $content = null)
{
global $_oscitas_accordion;
extract(shortcode_atts(array('title' => 'title', 'class' => ''), $params));
$con = do_shortcode($content);
$index = count($_oscitas_accordion) - 1;
$id = isset($_oscitas_accordion[$index]['details']) ? 'details-' . $index . '-' . count($_oscitas_accordion[$index]['details']) : 'details-' . $index . '-0';
$const = get_defined_constants();
$_oscitas_accordion[$index]['details'][] = <<<EOS
<div class="panel panel-default{$const['EBS_CONTAINER_CLASS']}">
<div class="panel-heading{$const['EBS_CONTAINER_CLASS']}">
<h4 class="panel-title{$const['EBS_CONTAINER_CLASS']}">
<a class="accordion-toggle{$const['EBS_CONTAINER_CLASS']} collapsed" data-toggle="collapse"
data-parent="#oscitas-accordion-{$index}"
href="#{$id}">
{$title}
</a>
</h4>
</div>
<div id="{$id}" class="panel-collapse collapse {$class}{$const['EBS_CONTAINER_CLASS']}">
<div class="panel-body{$const['EBS_CONTAINER_CLASS']}">{$con}</div>
</div>
</div>
EOS;
}
开发者ID:rubenberttpingol,项目名称:nsc.edu.ph,代码行数:25,代码来源:plugin_shortcode.php
示例6: saveState
/**
* Save the max id of every table. Thus when we convert again, when can delete id larger then the saved max id.
*
* @access public
* @return void
*/
public function saveState()
{
/* Get user defined tables. */
$constants = get_defined_constants(true);
$userConstants = $constants['user'];
/* These tables needn't save. */
unset($userConstants['TABLE_BURN']);
unset($userConstants['TABLE_GROUPPRIV']);
unset($userConstants['TABLE_PROJECTPRODUCT']);
unset($userConstants['TABLE_PROJECTSTORY']);
unset($userConstants['TABLE_STORYSPEC']);
unset($userConstants['TABLE_TEAM']);
unset($userConstants['TABLE_USERGROUP']);
/* Get max id of every table. */
foreach ($userConstants as $key => $value) {
if (strpos($key, 'TABLE') === false) {
continue;
}
if ($key == 'TABLE_COMPANY') {
continue;
}
$state[$value] = (int) $this->dao->select('MAX(id) AS id')->from($value)->fetch('id');
}
$this->session->set('state', $state);
}
开发者ID:laiello,项目名称:zentaoms,代码行数:31,代码来源:model.php
示例7: setUp
/**
* Set up
*
* @return void
*/
public function setUp()
{
//session_start();
// cleaning constants
if (PMA_HAS_RUNKIT) {
$this->oldIISvalue = 'non-defined';
$defined_constants = get_defined_constants(true);
$user_defined_constants = $defined_constants['user'];
if (array_key_exists('PMA_IS_IIS', $user_defined_constants)) {
$this->oldIISvalue = PMA_IS_IIS;
runkit_constant_redefine('PMA_IS_IIS', null);
} else {
runkit_constant_add('PMA_IS_IIS', null);
}
$this->oldSIDvalue = 'non-defined';
if (array_key_exists('SID', $user_defined_constants)) {
$this->oldSIDvalue = SID;
runkit_constant_redefine('SID', null);
} else {
runkit_constant_add('SID', null);
}
}
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
$GLOBALS['server'] = 0;
$GLOBALS['PMA_Config'] = new PMA\libraries\Config();
$GLOBALS['PMA_Config']->enableBc();
}
开发者ID:KoMyoThant,项目名称:phpmyadmin,代码行数:32,代码来源:PMA_headerLocation_test.php
示例8: getCurlOptionFromResponse
/**
* Returns a cURL option from a Response.
*
* @param Response $response Response to get cURL option from.
* @param integer $option cURL option to get.
*
* @throws \BadMethodCallException
* @return mixed Value of the cURL option.
*/
public static function getCurlOptionFromResponse(Response $response, $option = 0)
{
switch ($option) {
case 0:
// 0 == array of all curl options
$info = array();
foreach (self::$curlInfoList as $option => $key) {
$info[$key] = $response->getInfo($option);
}
break;
case CURLINFO_HTTP_CODE:
$info = $response->getStatusCode();
break;
case CURLINFO_SIZE_DOWNLOAD:
$info = $response->getHeader('Content-Length');
break;
default:
$info = $response->getInfo($option);
break;
}
if (!is_null($info)) {
return $info;
}
$constants = get_defined_constants(true);
$constantNames = array_flip($constants['curl']);
throw new \BadMethodCallException("Not implemented: {$constantNames[$option]} ({$option}) ");
}
开发者ID:alnutile,项目名称:drunatra,代码行数:36,代码来源:CurlHelper.php
示例9: run
public function run(&$params)
{
if (!defined('BUILD_LITE_FILE')) {
return;
}
$litefile = C('RUNTIME_LITE_FILE', null, RUNTIME_PATH . 'lite.php');
if (is_file($litefile)) {
return;
}
$defs = get_defined_constants(true);
$content = 'namespace {$GLOBALS[\'_beginTime\'] = microtime(TRUE);';
if (MEMORY_LIMIT_ON) {
$content .= '$GLOBALS[\'_startUseMems\'] = memory_get_usage();';
}
// 生成数组定义
unset($defs['user']['BUILD_LITE_FILE']);
$content .= $this->buildArrayDefine($defs['user']) . '}';
// 读取编译列表文件
$filelist = is_file(CONF_PATH . 'lite.php') ? include CONF_PATH . 'lite.php' : array(THINK_PATH . 'Common/functions.php', COMMON_PATH . 'Common/function.php', CORE_PATH . 'Think' . EXT, CORE_PATH . 'Hook' . EXT, CORE_PATH . 'App' . EXT, CORE_PATH . 'Dispatcher' . EXT, CORE_PATH . 'Log' . EXT, CORE_PATH . 'Log/Driver/File' . EXT, CORE_PATH . 'Route' . EXT, CORE_PATH . 'Controller' . EXT, CORE_PATH . 'View' . EXT, CORE_PATH . 'Storage' . EXT, CORE_PATH . 'Storage/Driver/File' . EXT, CORE_PATH . 'Exception' . EXT, BEHAVIOR_PATH . 'ParseTemplateBehavior' . EXT, BEHAVIOR_PATH . 'ContentReplaceBehavior' . EXT);
// 编译文件
foreach ($filelist as $file) {
if (is_file($file)) {
$content .= compile($file);
}
}
// 处理Think类的start方法
$content = preg_replace('/\\$runtimefile = RUNTIME_PATH(.+?)(if\\(APP_STATUS)/', '\\2', $content, 1);
$content .= "\nnamespace { Think\\Think::addMap(" . var_export(\Think\Think::getMap(), true) . ");";
$content .= "\nL(" . var_export(L(), true) . ");\nC(" . var_export(C(), true) . ');Think\\Hook::import(' . var_export(\Think\Hook::get(), true) . ');Think\\Think::start();}';
// 生成运行Lite文件
file_put_contents($litefile, strip_whitespace('<?php ' . $content));
}
开发者ID:beyondzgz,项目名称:thinkphp,代码行数:32,代码来源:BuildLiteBehavior.class.php
示例10: help
function help()
{
$const = get_defined_constants(true);
ob_start();
echo '<br />';
echo '------------Constants: --------------------<br />';
foreach ($const['user'] as $key => $name) {
echo "{$key} => {$name}<br />";
}
$method = get_class_methods($this);
echo '<br />';
echo '-------------Methods: ---------------<br />';
print_r($method);
$include = get_included_files();
echo '<br />';
echo '-------------Include Files ---------------<br />';
print_r($include);
$header = getallheaders();
echo '<br />';
echo '-------------Header: ---------------<br />';
print_r($header);
$msg = ob_get_contents();
ob_end_clean();
$this->getError($msg);
}
开发者ID:ngukho,项目名称:mvc-cms,代码行数:25,代码来源:caobox.php
示例11: mysqli_field_flags
function mysqli_field_flags($result, $field_offset)
{
static $flags;
$flags_num = mysqli_fetch_field_direct($result, $field_offset)->flags;
if (!isset($flags)) {
$flags = array();
$constants = get_defined_constants(true);
foreach ($constants['mysqli'] as $c => $n) {
if (preg_match('/MYSQLI_(.*)_FLAG$/', $c, $m)) {
if (!array_key_exists($n, $flags)) {
$flags[$n] = $m[1];
}
}
}
}
$result = array();
foreach ($flags as $n => $t) {
if ($flags_num & $n) {
$result[] = $t;
}
}
$return = implode(' ', $result);
$return = str_replace('PRI_KEY', 'PRIMARY_KEY', $return);
$return = strtolower($return);
return $return;
}
开发者ID:guoyu07,项目名称:MySQLi-Function,代码行数:26,代码来源:mysqli_field_flags.php
示例12: info
static function info($type = 1)
{
$type_list = array('basic', 'const', 'variable', 'function', 'class', 'interface', 'file');
if (is_int($type) && $type < 7) {
$type = $type_list[$type];
}
switch ($type) {
case 'const':
$const_arr = get_defined_constants(true);
return $const_arr['user'];
//2因作用域,请在外边直接调用函数
//2因作用域,请在外边直接调用函数
case 'variable':
return 'please use: get_defined_vars()';
case 'function':
$fun_arr = get_defined_functions();
return $fun_arr['user'];
case 'class':
return array_slice(get_declared_classes(), 125);
case 'interface':
return array_slice(get_declared_interfaces(), 10);
case 'file':
return get_included_files();
default:
return array('system' => php_uname(), 'service' => php_sapi_name(), 'php_version' => PHP_VERSION, 'frame_name' => config('frame|name'), 'frame_version' => config('frame|version'), 'magic_quotes' => get_magic_quotes_gpc(), 'time_zone' => date_default_timezone_get());
}
}
开发者ID:art-youth,项目名称:framework,代码行数:27,代码来源:debug.php
示例13: render
/**
* {@inheritdoc}
*/
protected function render()
{
$constants = get_defined_constants(true);
if (!empty($constants["user"])) {
$maxLength = 0;
foreach ($constants["user"] as $name => $value) {
$maxLength = max($maxLength, strlen($name));
}
foreach ($constants["user"] as $name => $value) {
$name = str_pad($name, $maxLength, " ", STR_PAD_RIGHT);
switch (gettype($value)) {
case "string":
$value = str_replace(array("\n", "\r", "\t"), array("\\n", "\\r", "\\t"), $value);
break;
case "bool":
case "boolean":
$value = $value ? "true" : "false";
$value = "<<2>>{$value}";
break;
case "null":
case "NULL":
$value = "<<2>>null";
break;
}
$this->printText("<<3>>{$name} : <<0>>{$value}\n");
}
} else {
// no user constants
$this->printText("No user constants");
}
}
开发者ID:samleybrize,项目名称:bugzorcist,代码行数:34,代码来源:NcursesUserConstants.php
示例14: get_mapi_error_name
/**
* Function to get a human readable string from a MAPI error code
*
*@param int $errcode the MAPI error code, if not given, we use mapi_last_hresult
*@return string The defined name for the MAPI error code
*/
function get_mapi_error_name($errcode = null)
{
if ($errcode === null) {
$errcode = mapi_last_hresult();
}
if ($errcode !== 0) {
// get_defined_constants(true) is preferred, but crashes PHP
// https://bugs.php.net/bug.php?id=61156
$allConstants = get_defined_constants();
foreach ($allConstants as $key => $value) {
/**
* If PHP encounters a number beyond the bounds of the integer type,
* it will be interpreted as a float instead, so when comparing these error codes
* we have to manually typecast value to integer, so float will be converted in integer,
* but still its out of bound for integer limit so it will be auto adjusted to minus value
*/
if ($errcode == (int) $value) {
// Check that we have an actual MAPI error or warning definition
$prefix = substr($key, 0, 7);
if ($prefix == "MAPI_E_" || $prefix == "MAPI_W_") {
return $key;
}
}
}
} else {
return "NOERROR";
}
// error code not found, return hex value (this is a fix for 64-bit systems, we can't use the dechex() function for this)
$result = unpack("H*", pack("N", $errcode));
return "0x" . $result[1];
}
开发者ID:tuksik,项目名称:zarafa-rest-api,代码行数:37,代码来源:mapi.util.php
示例15: quickCacheConstants
/**
* Back compat. with `QUICK_CACHE_` constants.
*
* @since 150422 Rewrite.
*/
public static function quickCacheConstants()
{
if (!($constants = get_defined_constants(true)) || empty($constants['user'])) {
return;
// Nothing to do; i.e. no user-defined constants.
}
foreach ($constants['user'] as $_constant => $_value) {
if (stripos($_constant, 'QUICK_CACHE_') !== 0) {
continue;
// Nothing to do here.
}
if (!($_constant_sub_name = substr($_constant, 12))) {
continue;
// Nothing to do here.
}
if (!defined(GLOBAL_NS . '_' . $_constant_sub_name)) {
define(GLOBAL_NS . '_' . $_constant_sub_name, $_value);
}
}
unset($_constant, $_value);
// Housekeeping.
if (isset($_SERVER['QUICK_CACHE_ALLOWED']) && !isset($_SERVER[GLOBAL_NS . '_ALLOWED'])) {
$_SERVER[GLOBAL_NS . '_ALLOWED'] = $_SERVER['QUICK_CACHE_ALLOWED'];
}
}
开发者ID:raamdev,项目名称:zcpzcldiff,代码行数:30,代码来源:AdvCacheBackCompat.php
示例16: osc_theme_slider
function osc_theme_slider($params, $content = null)
{
global $_oscitas_slider, $_oscitas_slider_slides;
$index = $_oscitas_slider['current_id'];
if (!isset($_oscitas_slider_slides[$index])) {
$_oscitas_slider_slides[$index] = array();
}
extract(shortcode_atts(array('title' => 'title', 'image' => '', 'caption' => '', 'active' => '', 'slideid' => count($_oscitas_slider_slides[$index])), $params));
$const = get_defined_constants();
if (!empty($image)) {
$_oscitas_slider[$index]['bullets'][] = '<li data-target="#oscitas-slider-' . $index . '" data-slide-to="' . $slideid . '" class="' . $active . '"></li>';
$_oscitas_slider_slides[$index][$slideid] = array();
if (!empty($caption)) {
$caption = '<p class="ebs-caption">' . $caption . '</p>';
}
if (!empty($content)) {
$caption = '<p class="ebs-caption">' . $content . '</p>';
}
$_oscitas_slider[$index]['details'][] = <<<EOS
<div class="item {$active}{$const['EBS_CONTAINER_CLASS']}">
<img src="{$image}" >
<div class="carousel-caption{$const['EBS_CONTAINER_CLASS']}">
<h3 class="ebs-caption">{$title}</h3>
{$caption}
</div>
</div>
EOS;
}
}
开发者ID:chypriote,项目名称:wp-video,代码行数:29,代码来源:plugin_shortcode.php
示例17: getMatches
/**
* {@inheritDoc}
*/
public function getMatches(array $tokens, array $info = array())
{
$const = $this->getInput($tokens);
return array_filter(array_keys(get_defined_constants()), function ($constant) use($const) {
return AbstractMatcher::startsWith($const, $constant);
});
}
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:10,代码来源:ConstantsMatcher.php
示例18: render
public function render($file, $data = array())
{
// lazy init
if (!$this->parser) {
include 'Parser.php';
include 'Lexer.php';
include 'Renderer.php';
include 'TemplateDataObject.php';
$renderers = (include 'renderers.php');
$this->parser = new Parser(new Lexer(), new Renderer($renderers, $this));
}
if (empty($file)) {
throw new \Exception('Template filename is empty.');
}
$this->data = new TemplateDataObject($data, \ArrayObject::ARRAY_AS_PROPS);
// inject constants into template data
$constants = get_defined_constants(true);
$constants = $constants['user'];
foreach ($constants as $name => $constant) {
$this->data[$name] = $constant;
}
$compiledFile = $this->config['cache_path'] . $file;
$sourceFile = $this->config['payload'] . $file;
$this->compileFile($sourceFile, $compiledFile);
$rendered = $this->exec($compiledFile);
// make paths work in subfolder installations
// eg. localhost/client/project/index.php
//$rendered = str_replace('href="/', 'href="'.APP_ROOT, $rendered);
//$rendered = str_replace('src="/', 'src="'.APP_ROOT, $rendered);
//$rendered = str_replace('action="/', 'action="'.APP_ROOT, $rendered);
// todo: handle protocol-less src's eg. src="//jquery..."
return $rendered;
}
开发者ID:juancamiloestela,项目名称:RocketPHP,代码行数:33,代码来源:System.php
示例19: setImageFilter
function setImageFilter($image_f, $f, $hue)
{
//PARTE DE FILTROS
if (!is_numeric($f) && $f != '') {
$tmp = get_defined_constants();
$f = $tmp['IMG_FILTER_' . strtoupper($f)];
}
//Se um filtro foi escolhido
if ($f != '') {
$arr = array($image_f, $f);
if (isset($_GET['fp1'])) {
$arr[] = $_GET['fp1'];
}
if (isset($_GET['fp2'])) {
$arr[] = $_GET['fp2'];
}
if (isset($_GET['fp3'])) {
$arr[] = $_GET['fp3'];
}
if (isset($_GET['fp4'])) {
$arr[] = $_GET['fp4'];
}
call_user_func_array('imagefilter', $arr);
}
if ($hue != '') {
imagefilterhue($image_f, hexdec(substr($hue, 0, 2)), hexdec(substr($hue, 2, 2)), hexdec(substr($hue, 4, 2)));
}
}
开发者ID:soares289,项目名称:gojira,代码行数:28,代码来源:thumb.php
示例20: replaceDefineOnImport
public static function replaceDefineOnImport($match) {
$define = $match[1];
if (defined($define)) {
$r = get_defined_constants();
return $r[$define];
}
}
开发者ID:nbourguig,项目名称:concrete5,代码行数:7,代码来源:controller.php
注:本文中的get_defined_constants函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论