Exemplo n.º 1
0
 public function find_children($categoryId, $conn)
 {
     $this->categoryId = $categoryId;
     //finding left and right
     $sql = "SELECT CategoryName,dpth, rgt, lft FROM nested_category WHERE CategoryId={$categoryId}";
     $result = $conn->query($sql);
     if (is_null($result)) {
         return;
     }
     $row = $result->fetch_assoc();
     if (is_null($row)) {
         return;
     }
     $this->categoryName = array_shift($row);
     $myDpth = array_shift($row);
     $myRgt = array_shift($row);
     $myLft = array_shift($row);
     $sql = "SELECT categoryName, categoryId FROM nested_category WHERE lft>{$myLft} and rgt<{$myRgt} and dpth={$myDpth}+1";
     $result = $conn->query($sql);
     if (is_null($result)) {
         return;
     }
     while ($row = mysqli_fetch_array($result)) {
         $b = new SimpleClass($row["categoryName"], $row["categoryId"]);
         $b->find_children($row["categoryId"], $conn);
         array_push($this->child_categories, $b);
     }
 }
 /**
  * tag_open method
  *
  * @param string $parser
  * @param string $tag
  * @param array $attribs
  */
 function tag_open($parser, $tag, $attribs)
 {
     $node = new SimpleClass();
     $node->setArray($attribs);
     $node->setProp("_TAGNAME", $tag);
     $this->datas[] = $node;
 }
 public function __construct()
 {
     parent::__construct();
     $this->name = 'Complex Class Instance';
     $this->dataStore = array('foo', 1, 'dateInfo' => new \DateTime(), 'classInfo' => new SimpleClass());
     for ($i = 0; $i < 5; ++$i) {
         $this->assocArray['position_' . $i] = $i;
         $this->numArray[] = $i;
     }
 }
Exemplo n.º 4
0
 /**
  * helper function initialise a simpleClass Object
  *
  * @param string $class
  * @param string $tree
  * @return string
  */
 function _initClass($tag, $attribs = array())
 {
     $node = new SimpleClass();
     $node->setArray($attribs);
     $node->setProp("_TAGNAME", $tag);
     $this->datas[] = $node;
     //$this->_debug( 3, '', 'Initialized simple class', 'OK' );
 }
Exemplo n.º 5
0
 public function testSimpleClassConversion()
 {
     $o = new SimpleClass();
     $o->setName("test");
     $o->setDescription("description");
     $this->assertEquals("test", $o->getName());
     $this->assertEquals("description", $o->getDescription());
     $json = $o->toJSON();
     $this->assertEquals('{"name":"test","desc":"description"}', $json);
     $newO = new SimpleClass();
     $newO->fromJson($json);
     $this->assertEquals($o, $newO);
 }
Exemplo n.º 6
0
 function foo()
 {
     $args = func_get_args();
     parent::foo();
 }
 /**
  * @covers SimpleClass::simpleFunction
  */
 public function testSimpleFunction()
 {
     $this->assertEquals('Simple', $this->object->simpleFunction());
 }
Exemplo n.º 8
0
 /**
  * @requires PHP 7.0
  * @expectedException \Error
  * @expectedExceptionMessageRegExp /Call to undefined method/
  */
 public function testNonExistingMethodCall()
 {
     $this->expectOutputRegex('/Call to undefined method/');
     $obj = new SimpleClass();
     $obj->nonExistingMethod();
 }
Exemplo n.º 9
0
<?php

require 'simpleclass.php';
$s = new SimpleClass();
$s->displayvar();
$s->var = 'other value';
$s->displayvar();
var_dump($s);
Exemplo n.º 10
0
$func("xudedong");
$func = "echoit";
$func("vcbnm");
?>
 

<?php 
class SimpleClass
{
    // property declaration
    public $var = 'a default value,<br />';
    // method declaration
    public function displayVar()
    {
        echo $this->var;
    }
}
$sim = new SimpleClass();
$sim->displayVar();
?>
 









Exemplo n.º 11
0
<?php

require_once "simple_class.php";
$simple_class1 = new SimpleClass();
$simple_class2 = new SimpleClass();
$simple_class3 = new SimpleClass();
$simple_class4 = new SimpleClass();
$simple_class5 = new SimpleClass();
echo "Simple Class called <b>5</b> times: <br />";
echo "Number of 'connections': " . SimpleClass::getTotalCalls();
echo "<br /><br />";
require_once "singleton.php";
$simple_class1 = Singleton::getInstance();
$simple_class2 = Singleton::getInstance();
$simple_class3 = Singleton::getInstance();
$simple_class4 = Singleton::getInstance();
$simple_class5 = Singleton::getInstance();
echo "<br /><br />";
echo "Singleton called <b>5</b> times: <br />";
echo "Number of 'connections': " . Singleton::getTotalCalls();
Exemplo n.º 12
0
 function displayVar()
 {
     echo "Classe Herdeira\n";
     parent::displayVar();
 }
Exemplo n.º 13
0
	<article>
	<h2>Steg 1 - intro teori</h2>
	<p>Läste på om begreppen: objekt, metod, egenskaper/properties och inkapsling.
	<p>Slår på all error-reporting för php
	<?php 
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
	</article>

	<article>
	<h2>Steg 2 - att använda en enkel klass</h2>
	<p>
	<?php 
$sp = new SimpleClass();
$sp->DisplayVar();
$sp->var = "a new value";
echo "<p>";
$sp->DisplayVar();
?>
	</article>

	<article>
	<h2>Steg 3 - en tärningsklass</h2>
	<p>Simulera tärningsslag genom att ange ett värde för GET-parametern <strong>rolls</strong>
	<?php 
$d = new CDice();
if (isset($_GET['rolls'])) {
    $n = (int) filter_input(INPUT_GET, 'rolls');
    echo "<p>Slår tärningen {$n} gånger";
Exemplo n.º 14
0
 function displayVar()
 {
     echo "Расширенный класс\n";
     parent::displayVar();
 }
Exemplo n.º 15
0
 function displayVar()
 {
     echo "Extending class\n";
     parent::displayVar();
 }
Exemplo n.º 16
0
    //public $var5 = $myVar;
    // правильное определение свойств:
    public $var6 = myConstant;
    public $var7 = array(true, false);
    // Это разрешено только в PHP 5.3.0 и более поздних версиях.
    public $var8 = <<<'EOD'
hello world
EOD;
    // MY
    public function GetClassInfo()
    {
        return SimpleClass::class;
    }
}
define("myConstant", "myConstant");
$SimleObj = new SimpleClass();
?>
<pre><?php 
// var_dump($SimleObj);
?>
</pre><?php 
?>
<pre><?php 
echo $SimleObj->GetClassInfo();
?>
</pre><?php 
?>
<pre><?php 
echo $SimleObj->var1;
?>
</pre><?php