当前位置: 首页>>代码示例>>PHP>>正文


PHP helper::setMember方法代码示例

本文整理汇总了PHP中helper::setMember方法的典型用法代码示例。如果您正苦于以下问题:PHP helper::setMember方法的具体用法?PHP helper::setMember怎么用?PHP helper::setMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在helper的用法示例。


在下文中一共展示了helper::setMember方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: stdclass

#!/usr/bin/env php
<?php 
<<<TC
title: testing the setMember method with multi level.
TC;
/* Include the helper class. */
include '../../helper.class.php';
/* Create two objects named obj and obj2. */
$obj = new stdclass();
$obj->user = new stdclass();
$obj->user->name = 'Tom';
helper::setMember('obj', 'user.name', 'Mary');
// overide the exists key.
helper::setMember('obj', 'user.age', 20);
// add a child key to an existing key.
helper::setMember('obj', 'home.address', new stdclass());
// add a child key even the parent doesn't exist.
helper::setMember('obj', 'home.address.postcode', '10000');
// three level.
echo $obj->user->name . "\n";
echo $obj->user->age . "\n";
print_r($obj->home->address);
开发者ID:xianglongzhang,项目名称:zentaopms,代码行数:22,代码来源:110.setmember.multilevel.php

示例2: set

 /**
  * Set the value of a member. the member can be the foramt like db.user.
  * 
  * <code>
  * <?php
  * $lang->set('version', '1.0); 
  * ?>
  * </code>
  * @param   string  $key    the key of the member, can be father.child
  * @param   mixed   $value  the value
  * @access  public
  * @return  void
  */
 public function set($key, $value)
 {
     helper::setMember('lang', $key, $value);
 }
开发者ID:leowh,项目名称:colla,代码行数:17,代码来源:router.class.php

示例3: stdclass

#!/usr/bin/env php
<?php 
<<<TC
title: testing the setMember method.
TC;
/* Include the helper class. */
include '../../helper.class.php';
/* Create two objects named obj and obj2. */
$obj = new stdclass();
$obj->key1 = 'value1';
$obj2 = new stdclass();
$obj2->key1 = 'value2.1';
helper::setMember('obj', 'key1', 'value1.1');
// overide the exists key.
helper::setMember('obj', 'key2', 'value2');
// add a new key.
helper::setMember('obj', 'key3', 3);
// set an int value.
helper::setMember('obj', 'key4', array(1, 2, 3));
// set an array value.
helper::setMember('obj', 'key5', $obj2);
// set an object value.
echo $obj->key1 . "\n";
echo $obj->key2 . "\n";
echo $obj->key3 . "\n";
print_r($obj->key4);
print_r($obj->key5);
开发者ID:xianglongzhang,项目名称:zentaopms,代码行数:27,代码来源:101.setmember.onelevel.php

示例4: stdClass

 * @link        http://www.zentao.net
 * @license     http://opensource.org/licenses/lgpl-3.0.html LGPL
 */
include '../../helper.class.php';
$config = new stdClass();
/* 测试一维属性的修改。*/
$config->user = 'wwccss';
helper::setMember('config', 'user', 'chunsheng');
echo $config->user . "\n";
/* 赋值的变量含有单双引号。*/
$config->name = 'wwccss';
helper::setMember('config', 'name', "wang'chun\"sheng");
echo $config->name . "\n";
/* 赋值的变量为一个数组。*/
$config->users = array(1, 2, 3);
helper::setMember('config', 'users', array('a', 'b', 'c'));
print_r($config->users);
/* 赋值的变量为一个对象。*/
$config->obj = array(1, 2, 3);
helper::setMember('config', 'obj', new stdClass());
print_r($config->obj);
/* 测试二维属性的修改。*/
$config->db->host = 'localhost';
$config->db->user = 'wwccss';
$config->db->param = array();
helper::setMember('config', 'db.host', "localhost");
helper::setMember('config', 'db.user', "chunsheng'.wang");
helper::setMember('config', 'db.param', array('1', '2', '3'));
echo $config->db->host . "\n";
echo $config->db->user . "\n";
print_r($config->db->param);
开发者ID:take7yo,项目名称:zentaophp,代码行数:31,代码来源:case002.php

示例5: stdClass

#!/usr/bin/env php
<?php 
/**
 * 测试array2Object方法。
 *
 * @copyright   Copyright 2009-2010 青岛易软天创网络科技有限公司(www.cnezsoft.com)
 * @author      chunsheng.wang <chunsheng@cnezsoft.com>
 * @package     Testing
 * @version     $Id$
 * @link        http://www.zentao.net
 * @license     http://opensource.org/licenses/lgpl-3.0.html LGPL
 */
include '../../helper.class.php';
$array['a1'] = '1';
$array['a2'] = '2';
$array['a3']['b1'] = '3';
$array['a3']['b2'] = '4';
$array['a4']['b3']['c1'] = '5';
$array['a5'] = '6';
$array['a6']['b4'] = '7';
$array['a7']['b5']['c2'] = '8';
$config = new stdClass();
eval(helper::array2object($array, 'config'));
print_r($config);
echo $config->a3->b1;
echo "\n";
helper::setMember('config', 'a3.b1', 10);
echo $config->a3->b1;
echo "\n";
开发者ID:dyp8848,项目名称:zentaophp,代码行数:29,代码来源:case001.php


注:本文中的helper::setMember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。