示例#1
0
 public function __construct($array = null)
 {
     parent::__construct();
     if ($array != null) {
         foreach ($array as $row => $v) {
             $this->{$row} = $v;
         }
     }
 }
示例#2
0
 public function saveNew()
 {
     $this->secret = $this->generateSecret();
     $this->date = date('Y-m-d H:i:s');
     $this->official = 0;
     $this->status = 0;
     if (empty($this->url)) {
         $this->url = '';
     }
     return parent::saveNew();
 }
示例#3
0
 public function saveNew()
 {
     $this->id = '';
     $user = new User();
     $user = $user->get($this->uid);
     if (!$user) {
         throw new Exception('user not found');
     }
     $this->country = $user->country;
     $id = parent::saveNew();
     return $id;
 }
示例#4
0
<?php

class BasicClass
{
    const CLASS_CONSTANT = 12.7;
    public function multiply($x)
    {
        return $x * self::CLASS_CONSTANT;
    }
}
echo BasicClass::CLASS_CONSTANT . '<br />' . PHP_EOL;
$inst = new BasicClass();
echo $inst->multiply(3) . '<br />' . PHP_EOL;
示例#5
0
 public function __construct($name)
 {
     self::$staticVariable = $name;
 }
示例#6
0
		if (isset($this)) {
			echo '$this is defined (';
			echo get_class($this);
			echo ")<br />";
		} else {
			echo "\$this is not defined.<br />";
		}
	}
}

class B
{
	function boo()
	{
		A::foo();
	}
}

$a = new BasicClass();
$a->foo();

A::foo();

$b = new B();

$b->boo();

B::boo();


?>
示例#7
0
 public function saveNew()
 {
     $this->id = '';
     $this->quality = 1;
     $this->pendingUnits = 0;
     $this->money = 0;
     $this->maxEmployees = self::MIN_EMPLOYEES;
     $user = new User();
     $user = $user->get($this->uid);
     if (!$user) {
         throw new Exception('user not found');
     }
     if ($user->gold < self::CREATION_COST) {
         throw new Exception('no gold enough');
     }
     $id = parent::saveNew();
     if ($id) {
         $user->gold -= self::CREATION_COST;
         $user->save();
     }
     return $id;
 }
示例#8
0
 /**
  * creates a new user
  * 
  * @return mixed (uid or false)
  */
 public function saveNew()
 {
     $this->status = self::STATUS_PENDING;
     $this->gold = 0;
     $this->xp = 0;
     $this->language = 'en';
     $q = "select `id` from `" . $this->table . "` where `email`='" . $this->email . "' OR `nick`='" . $this->nick . "' LIMIT 1";
     $rows = Service::getDB()->query($q);
     if (sizeof($rows) > 0) {
         return false;
     }
     return parent::saveNew();
 }
示例#9
0
<?php

class BasicClass
{
    private $var1;
    protected $var2;
    public $var3;
    public function __construct($var)
    {
        $this->var1 = $var;
        $this->var2 = $var;
        $this->var3 = $var;
    }
    public function doubleVar3()
    {
        $this->var3 = $this->var3 . ' ' . $this->var3;
    }
    public function getVar1()
    {
        return $this->var1;
    }
}
$inst = new BasicClass('foo');
echo $inst->getVar1() . '<br />' . PHP_EOL;
$inst->doubleVar3();
echo $inst->var3;