1. Go to this page and download the library: Download gorgo/golib library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gorgo / golib example snippets
use golib\Types\Enum;
class MyEnum extends Enum {
function getPossibleValueArray(){
return array('a','b','c');
}
}
$myEnum = new MyEnum('b'); // will be accepted
echo $myEnum->geValue(); // 'b'
$exceptionEnum = new MyEnum('g'); // a EnumException will be Trown beause g is not valid
$failEnum = new MyEnum('g',EnumDef::ERROR_MODE_TRIGGER_ERROR); // just triggers an PHP error
use golib\Types\ConstEnum;
class MyEnum extends ConstEnum {
const INTEGER = 1;
const STRING = 2;
const ARRAY = 3;
}
$myEnum = new MyEnum(MyEnum::INTEGER); // of course valid
$value = 2;
$myEnum = new MyEnum($value); // also valid because 2 is defined as ARRAY
$myEnum = new MyEnum(6); // will throw a EnumException
$myEnum = new MyEnum(6, EnumDef::ERROR_MODE_TRIGGER_ERROR); // instead of a exception a error is triggered
$query = sprintf("SELECT firstname, lastname, address, age FROM friends ");
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
echo $row['firstname'];
echo $row['lastname'];
echo $row['address'];
echo $row['age'];
}
use golib\Props;
class Person extends Props {
public $firstname = NULL;
public $lastname = NULL;
public $adress = NULL;
public $age = NULL;
}