Author: Rushui
Inheritance: extends MY_Controller
Exemple #1
0
<?php

//this is how you instantiate an object
$obj = new example();
//this is how you assign a value to a public property
$obj->name = 'steve';
//this is how you call a public method
$obj->printHelloWorld();
//this is how you print the contents of an array or object
print_r($obj);
//this is how you define a class
class example
{
    //this is how you define a public property
    public $name;
    //this is the magic method constructor
    public function __construct()
    {
        echo 'Hello world... ' . $this->name;
    }
    //this is creating a public method
    public function printHelloWorld()
    {
        echo 'Hello world... ' . $this->name;
    }
}
<?php

require_once 'includes/example.php';
$myExample = new example();
// performs some basic operation
echo '<b>Attempt to perform basic operations</b><br />' . "\n";
try {
    echo 'Your name is <i>' . $myExample->giveMeSomeData('name') . '</i><br />' . "\n";
    $myExample->changeYourState('I am using this function from the local environement');
    echo 'Your status request has been accepted<br />' . "\n";
} catch (Exception $e) {
    echo nl2br($e->getMessage()) . '<br />' . "\n";
}
// performs some strategic operation, locally allowed
echo '<br /><b>Attempt to store strategic data</b><br />' . "\n";
try {
    $myExample->writeSomething('Strategic string!');
    echo 'Strategic data succefully stored';
} catch (Exception $e) {
    echo nl2br($e->getMessage());
}
Exemple #3
0
<?php

# This file illustrates the low-level C++ interface
# created by SWIG.  In this case, all of our C++ classes
# get converted into function calls.
include "example.php";
# ----- Object creation -----
print "Creating some objects:\n";
$c = example::CircleFactory(10);
print "    Created circle \$c with area " . $c->area() . "\n";
$s = new Square(10);
print "    Created square \$s\n";
# ----- Access a static member -----
print "\nA total of " . Shape::nshapes() . " shapes were created\n";
# ----- Member data access -----
# Set the location of the object.
# Note: methods in the base class Shape are used since
# x and y are defined there.
$c->x = 20;
$c->y = 30;
$s->x = -10;
$s->y = 5;
print "\nHere is their current position:\n";
print "    Circle = (" . $c->x . "," . $c->y . ")\n";
print "    Square = (" . $s->x . "," . $s->y . ")\n";
# ----- Call some methods -----
print "\nHere are some properties of the shapes:\n";
foreach (array($c, $s) as $o) {
    print "    " . get_class($o) . " \$o\n";
    print "        x         = " . $o->x . "\n";
    print "        y         = " . $o->y . "\n";
 static function deactivate($network_wide)
 {
     foreach ($this as $value) {
         page - template - example::delete_template($value);
     }
 }
Exemple #5
0
# First create some objects using the pointer library.
print "Testing the pointer library\n";
$a = example::new_intp();
$b = example::new_intp();
$c = example::new_intp();
example::intp_assign($a, 37);
example::intp_assign($b, 42);
print "\ta = {$a}\n";
print "\tb = {$b}\n";
print "\tc = {$c}\n";
# Call the add() function wuth some pointers
example::add($a, $b, $c);
# Now get the result
$r = example::intp_value($c);
print "\t37 + 42 = {$r}\n";
# Clean up the pointers
example::delete_intp($a);
example::delete_intp($b);
example::delete_intp($c);
# Now try the typemap library
# This should be much easier. Now how it is no longer
# necessary to manufacture pointers.
print "Trying the typemap library\n";
$r = example::sub(37, 42);
print "\t37 - 42 = {$r}\n";
# Now try the version with multiple return values
# print "Testing multiple return values\n";
# $a = example::divide(42,37);
# $q = $a[0]
# $r = $a[1]
# print "	42/37 = $q remainder $r\n";
Exemple #6
0
   <th colspan="2" bgcolor="blue"><font color="white">Enter Something</font></th>
      <tr>
      <td>Name</td>
      <td><input type="text" name="username" size="20" value="<?php 
print $username;
?>
"></td>
      </tr>
      <tr>
      <td>A word</td>
      <td><input type="text" name="string" size="20" value="<?php 
print $string;
?>
"></td>
      </tr>
      <th colspan="2" bgcolor="blue"><font color="white"><input type="submit" name="submit" value="Submit"></font></td>   
<!-- ---  end form  --- -->
<?php 
if ($string == "") {
    echo "   </table></center></form>\n";
} else {
    echo "      <tr>\n" . "      <th colspan=\"2\">\n" . "      <font color=\"blue\">example extends sq, it's constructor says => ";
    $stuff = new example($string);
    echo "</font></th>\n" . "   </table></center></form>\n";
}
echo "function done() of class example spews => ";
$stuff->done();
?>
   
   
Exemple #7
0
# This file illustrates the manipulation of C++ references in PHP.
require "example.php";
# ----- Object creation -----
print "Creating some objects:\n";
$a = new Vector(3, 4, 5);
$b = new Vector(10, 11, 12);
print "    Created a: {$a->as_string()}\n";
print "    Created b: {$b->as_string()}\n";
# ----- Call an overloaded operator -----
# This calls the wrapper we placed around
#
#      operator+(const Vector &a, const Vector &)
#
# It returns a new allocated object.
print "Adding a+b\n";
$c = example::addv($a, $b);
print "    a+b ={$c->as_string()}\n";
# ----- Create a vector array -----
print "Creating an array of vectors\n";
$va = new VectorArray(10);
print "    va: size={$va->size()}\n";
# ----- Set some values in the array -----
# These operators copy the value of $a and $b to the vector array
$va->set(0, $a);
$va->set(1, $b);
$va->set(2, addv($a, $b));
# Get some values from the array
print "Getting some array values\n";
for ($i = 0; $i < 5; $i++) {
    print "    va[{$i}] = {$va->get($i)->as_string()}\n";
}
Exemple #8
0
// define other controller
// in this controller is exampled the use of models
_::define_controller('example_2', function () {
    // my code here...
    // declare need model example
    // this is not necessary since version 1.0.1
    _::declare_model('example');
    // making new record void
    $record = new example();
    // put value in the field of record
    $record->field_example = 'value of example';
    // in this case, insert new record in the table example
    // and return id of the new record
    $lastInsertID = $record->save();
    // in this case, use id for load record
    $record = new example($lastInsertID);
    // this show string(16) "value of example"
    var_dump($record->field_example);
    // set new value
    $record->field_example = 'new value';
    var_dump($record->field_example);
    // now this show new value
    // in this case, this work as "UPLOAD" query.
    $record->save();
    var_dump($record->field_example);
    // this show new value
    // this assign the value of record to var $value
    _::$view->assign('value', $record->field_example);
    // in the html, you able to use {$value} to show the value of $record
    // this request use example.tpl as html to return.
    _::$view->show('example');