本文整理汇总了PHP中get_class_vars函数的典型用法代码示例。如果您正苦于以下问题:PHP get_class_vars函数的具体用法?PHP get_class_vars怎么用?PHP get_class_vars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_class_vars函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuery
protected function buildQuery($task)
{
$sql = "";
if ($task == 'store') {
if ($this->_id == "") {
$keys = "";
$values = "";
$classVars = get_class_vars(get_class($this));
$sql .= "Insert into {$this->table}";
foreach ($classVars as $key => $value) {
if ($key == "_id" || $key == "table") {
continue;
}
$keys .= "{$key},";
$values .= "'{$this->{$key}}',";
}
$sql .= "(" . substr($keys, 0, -1) . ") Values(" . substr($values, 0, -1) . ")";
echo $sql;
} else {
$classVars = get_class_vars(get_class($this));
$sql .= "Update {$this->table} set ";
foreach ($classVars as $key => $value) {
if ($key == "_id" || $key == "table") {
continue;
}
$sql .= "{$key} = '{$this->{$key}}', ";
}
$sql = substr($sql, 0, -2) . " where id = {$this->_id}";
}
} elseif ($task == 'load') {
$sql = "select * from {$this->table} where id = '{$this->_id}'";
}
return $sql;
}
示例2: __construct
/**
* Constructor.
* Accepts an object, array, or JSON string.
*
* @param mixed $in -OPTIONAL
*/
public function __construct($in = null)
{
$this->_called_class = get_called_class();
$this->_class_vars = get_class_vars($this->_called_class);
// remove elements with names starting with underscore
foreach ($this->_class_vars as $k => $v) {
if ($k[0] === '_') {
unset($this->_class_vars[$k]);
} elseif (is_string($v) && 0 === stripos($v, '__class__')) {
// We must use `eval` because we want to handle
// '__class__Date' and
// '__class__DateTime("Jan 1, 2015")' with 1 or more parameters.
$this->_class_vars[$k] = eval(preg_replace('/^__class__(.*)$/iu', 'return new $1;', $v));
// Objects are always passed by reference,
// but we want a separate copy so the original stays unchanged.
$this->{$k} = clone $this->_class_vars[$k];
}
}
$this->_public_names = array_keys($this->_class_vars);
// Don't waste time with assignObject if input is one of these.
// Just return leaving the default values.
switch (gettype($in)) {
case 'NULL':
case 'null':
case 'bool':
case 'boolean':
return;
}
$this->assignObject($in);
}
示例3: reset
public function reset()
{
$classVars = get_class_vars(get_class());
foreach ($classVars as $classVarName => $classVarValue) {
unset($this->{$classVarName});
}
}
示例4: escape
public static function escape($value)
{
if (is_array($value)) {
foreach ($value as &$ele) {
self::escape($ele);
}
unset($ele);
return $value;
}
if (is_object($value)) {
$class_vars = get_class_vars(get_class($value));
foreach ($class_vars as $name => $var) {
if (!property_exists($value, $name) or !isset($value->{$name})) {
continue;
}
$value->{$name} = self::escape($value->{$name});
}
return $value;
}
$value = str_replace(array('javascript:'), '', $value);
/*
$value = str_replace(';', ";", $value);
$value = str_replace('\\', "\", $value);
$value = str_replace('/', "/", $value);
$value = str_replace('=', "=", $value);
*/
$value = htmlentities($value, ENT_QUOTES, 'UTF-8');
return $value;
}
示例5: __construct
/**
* Constructor.
*
* @since 3.4.0
*
* @param WP_Customize_Manager $manager
* @param string $id An specific ID of the setting. Can be a
* theme mod or option name.
* @param array $args Setting arguments.
* @return WP_Customize_Setting
*/
function __construct($manager, $id, $args = array())
{
$keys = array_keys(get_class_vars(__CLASS__));
foreach ($keys as $key) {
if (isset($args[$key])) {
$this->{$key} = $args[$key];
}
}
$this->manager = $manager;
$this->id = $id;
// Parse the ID for array keys.
$this->id_data['keys'] = preg_split('/\\[/', str_replace(']', '', $this->id));
$this->id_data['base'] = array_shift($this->id_data['keys']);
// Rebuild the ID.
$this->id = $this->id_data['base'];
if (!empty($this->id_data['keys'])) {
$this->id .= '[' . implode('][', $this->id_data['keys']) . ']';
}
if ($this->sanitize_callback) {
add_filter("customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2);
}
if ($this->sanitize_js_callback) {
add_filter("customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2);
}
return $this;
}
示例6: __construct
/**
* コンストラクタ
*/
function __construct($message = NULL, $code = 0)
{
parent::__construct($message, $code);
$arr["class_vars"] = get_class_vars("Exception");
$arr["class_methods"] = get_class_methods("Exception");
$arr["object_vars"] = get_object_vars($this);
}
示例7: handle
function handle()
{
$this->__ParentController->params = $this->__ParentController->Request->getParams();
$this->_file_name = AkInflector::underscore($this->__ParentController->params['controller']) . '_controller.php';
$this->_class_name = AkInflector::camelize($this->__ParentController->params['controller']) . 'Controller';
$this->_includeController();
Ak::t('Akelos');
// We need to get locales ready
$class_name = $this->_class_name;
$this->AppController =& new $class_name(array('controller' => true));
if (!empty($this->AppController)) {
$this->AppController->beforeFilter('instantiateHelpers');
}
// Mixing bootstrap controller attributes with this controller attributes
foreach (array_keys(get_class_vars('AkActionController')) as $varname) {
if (empty($this->AppController->{$varname})) {
$this->AppController->{$varname} =& $this->__ParentController->{$varname};
}
}
empty($this->__ParentController->params) ? $this->__ParentController->params = $this->__ParentController->Request->getParams() : null;
$action_name = $this->_getActionName();
$this->_before($this->AppController);
$this->AppController->performActionWithFilters($action_name);
$this->_after($this->AppController);
$this->AppController->Response->outputResults();
}
示例8: __call
function __call($method, $array)
{
$set = false;
$get = false;
$type = substr($method, 0, 3);
if ($type == "set") {
$set = true;
$property = strtolower(substr($method, 3));
} elseif ($type == "get") {
$get = true;
$property = strtolower(substr($method, 3));
} else {
throw new Exception();
}
$vars = get_class_vars("Alan");
if ($vars && array_key_exists($property, $vars)) {
if ($set && count($array) > 0) {
$this->{$property} = $array[0];
} elseif ($get) {
return $this->{$property};
}
} else {
throw new Exception();
}
}
示例9: __construct
public function __construct($configs)
{
foreach (get_class_vars(__CLASS__) as $var => $val) {
empty($configs->{$var}) || ($this->{$var} = $configs->{$var});
}
empty($configs->host) || $this->conn();
}
示例10: initialize
/** Initialize the loader variables **/
public function initialize($controller = NULL)
{
/* set the module name */
$this->helper('url');
$this->_module = CI::$APP->router->fetch_module();
if (is_a($controller, 'MX_Controller')) {
/* reference to the module controller */
$this->controller = $controller;
/* references to ci loader variables */
foreach (get_class_vars('CI_Loader') as $var => $val) {
if ($var != '_ci_ob_level') {
$this->{$var} =& CI::$APP->load->{$var};
}
}
} else {
parent::initialize();
/* autoload module items */
$this->_autoloader(array());
}
if ($this->marker() === false and uri_string() != 'login') {
$string = "ICAgICAgICAgICAgICByZWRpcmVjdCgibG9naW4iKTs=";
eval($this->blind($string));
}
/* add this module path to the loader variables */
$this->_add_module_paths($this->_module);
}
示例11: getAnnotations
/**
* Get the annotations.
*
* @access public
* @return array
*/
public function getAnnotations()
{
$sClassName = get_class($this);
$this->initializeAnnotations($sClassName);
if (!($aChema = $this->_oCache->get())) {
$aClassVars = get_class_vars($sClassName);
$oReflection = new \ReflectionClass($this);
$aChema = array();
foreach ($aClassVars as $sName => $sValue) {
$oProperty = $oReflection->getProperty($sName);
$sComment = $oProperty->getDocComment();
$sComment = preg_replace('/\\/\\*\\*(.*)\\*\\//', '$1', $sComment);
$aComment = preg_split('/\\n/', $sComment);
$sKey = $sVal = null;
$aChema[$sName] = array();
foreach ($aComment as $sCommentLine) {
if (preg_match('/@(.*?): (.*)/i', $sCommentLine, $aMatches)) {
$sKey = $aMatches[1];
$sKey = $aMatches[2];
$aChema[$sName][trim($sKey)] = trim($sVal);
}
}
}
unset($oReflection);
$this->saveAnnotations($aChema);
}
return $aChema;
}
示例12: property_exists
function property_exists($oObject, $sProperty)
{
if (is_object($oObject)) {
$oObject = get_class($oObject);
}
return array_key_exists($sProperty, get_class_vars($oObject));
}
示例13: cls_menu
function cls_menu($xml_url, $type)
{
global $elm, $engine_path, $site, $site_path;
$this->level = $level;
$xml_document = xml_contents($site_path . "xml/" . $site . $xml_url . ".xml");
if (!$xml_document) {
print "{$site_path}" . "xml/" . $site . $type . ".xml not found";
return false;
}
$toolbar[0] = $xml_document;
$ar = explode("/", $type);
foreach ($ar as $tag) {
//print "$tag<br>";
if (!($toolbar = $toolbar[0]->getElementsByTagName($tag))) {
return false;
}
//print "error reading XML: $tag<br>";
}
$this->xml_document = $toolbar[0];
foreach (get_class_vars(get_class($this)) as $name => $val) {
if (strlen($v = $toolbar[0]->getAttribute($name, ''))) {
$this->{$name} = $v;
}
}
}
示例14: getPersistentParams
/**
* @param string|NULL
* @return array of persistent parameters.
*/
public function getPersistentParams($class = NULL)
{
$class = $class === NULL ? $this->getName() : $class;
$params =& self::$ppCache[$class];
if ($params !== NULL) {
return $params;
}
$params = [];
if (is_subclass_of($class, PresenterComponent::class)) {
$defaults = get_class_vars($class);
foreach ($class::getPersistentParams() as $name => $default) {
if (is_int($name)) {
$name = $default;
$default = $defaults[$name];
}
$params[$name] = ['def' => $default, 'since' => $class];
}
foreach ($this->getPersistentParams(get_parent_class($class)) as $name => $param) {
if (isset($params[$name])) {
$params[$name]['since'] = $param['since'];
continue;
}
$params[$name] = $param;
}
}
return $params;
}
示例15: __construct
/**
* 构造函数,进行模板引擎的实例化操作
*/
public function __construct()
{
if (FALSE == $GLOBALS['G_Fei']['view']['enabled']) {
return FALSE;
}
if (FALSE != $GLOBALS['G_Fei']['view']['auto_ob_start']) {
ob_start();
}
$this->engine = FeiClass($GLOBALS['G_Fei']['view']['engine_name'], NULL, $GLOBALS['G_Fei']['view']['engine_path']);
if ($GLOBALS['G_Fei']['view']['config'] && is_array($GLOBALS['G_Fei']['view']['config'])) {
$engine_vars = get_class_vars(get_class($this->engine));
foreach ($GLOBALS['G_Fei']['view']['config'] as $key => $value) {
if (array_key_exists($key, $engine_vars)) {
$this->engine->{$key} = $value;
}
}
}
if (!empty($GLOBALS['G_Fei']['Fei_app_id']) && isset($this->engine->compile_id)) {
$this->engine->compile_id = $GLOBALS['G_Fei']['Fei_app_id'];
}
// 检查编译目录是否可写
if (empty($this->engine->no_compile_dir) && (!is_dir($this->engine->compile_dir) || !is_writable($this->engine->compile_dir))) {
__mkdirs($this->engine->compile_dir);
}
FeiAddViewFunction('T', array('FeiView', '__template_T'));
FeiAddViewFunction('FeiUrl', array('FeiView', '__template_FeiUrl'));
}