format('Y-m-d:h:i:s');
return $d;
}
// Thanks to http://docstore.mik.ua/orelly/webprog/pcook/ch07_10.htm for lots of below ...
// combine() adds numbers, concatenates strings, merges arrays,
// and ANDs bitwise and boolean arguments
function combine($a, $b) {
global $ret, $ia;
// echo $a . " and " . $b;
$ret = true;
$fa = "";
if (is_array($a) && is_array($b)) {
// echo " 95 " . sizeof($a);
$ia = true;
$aa=explode(",", $a[0]);
$bb=explode(",", $b[0]);
return array_merge($aa, $bb);
}
try {
if (1 == 1) { //strpos($a, ",") === false) {
if (function_exists($a)) { //is_callable($a)) {
// echo "99 " . $a . "()";
$c = $a();
// echo " 99.1 ";
// echo " ... " . $c->format('Y-m-d:h:i:s');
date_default_timezone_set('Europe/Lisbon');
$a = $c;
$fa = "y";
}
}
} catch (Exception $e) {
}
try {
if (1 == 1) { //if (strpos($b, ",") === false) {
if ($fa == "" && function_exists($b)) { //is_callable($b)) {
// echo "98 " . $b;
$c = $a;
$a = $b();
$b = $c;
}
}
} catch (Exception $e) {
}
if (is_object($a)) {
// echo "97 " . $b; // . $a->add($b)->format('Y-m-d:h:i:s');
$di = new DateInterval($b);
// echo "97.2 " . $b; // . $a->add($b)->format('Y-m-d:h:i:s');
$c = $a->add($di);
// echo "96 " . $c->format('Y-m-d:h:i:s'); // . $a->add($b)->format('Y-m-d:h:i:s');
return $c->format('Y-m-d:H:i:s');
}
if (is_numeric($a) && is_numeric($b)) {
return $a + $b;
}
if (is_string($a) && is_string($b)) {
return "$a$b";
}
if (is_bool($a) && is_bool($b)) {
return $a & $b;
}
$ret = false;
return false;
}
$ret = false;
if (isset($_GET['a']) && isset($_GET['b'])) {
//$result = combine(urldecode($_GET['a']), urldecode($_GET['b']));
$result = combine($_GET['a'], $_GET['b']);
} else if (isset($_POST['a']) && isset($_POST['b'])) {
//$result = combine(urldecode($_POST['a']), urldecode($_POST['b']));
$result = combine($_POST['a'], $_POST['b']);
}
?>
PHP Polymorphism Thoughts - RJM Programming - May, 2015
Combining Things
Result: " . var_dump($result) . "
";
} else if ($ret && !$ia) {
echo "Result: " . $result . "
";
}
?>