Beispiel #1
0
<?php

$exceptionCaught = false;
function testFunction($value1)
{
    adddlert("Welcome guest {$value1} !");
}
$exceptionMessage = false;
try {
    $result = testFunction(5);
    echo "Result is {$result}";
} catch (Exception $e) {
    $exceptionCaught = true;
    //echo "Exception caught ".$e->getMessage();
    $exceptionMessage = $e->getMessage();
}
assert($exceptionCaught, true);
assertGreater(strlen($exceptionMessage), 5);
$thrownExceptionCaught = false;
try {
    throw new Exception("What is this?");
} catch (Exception $e) {
    //echo "Exception caught ".$e->getMessage();
    $thrownExceptionCaught = true;
}
assert($thrownExceptionCaught, true);
testEnd();
Beispiel #2
0
 /**
  * @return mixed
  */
 public function successCallFromNSFunction()
 {
     return testFunction();
 }
<?php

class Flower
{
}
function testFunction(Flower $flower, int $a)
{
    var_dump($flower);
    var_dump($a);
}
testFunction(new Flower(), 1);
Beispiel #4
0
 <?php 
require "db_utils.php";
$con = getDbConnection();
testFunction();
echo "Its OK!";
}
assert($total, 15);
//****************************************
$value = '123';
$delta = 123;
$value = $value + $delta;
assert($value, 246);
$result = str_pad($value, 6, '0', STR_PAD_LEFT);
assert($result, '000246');
//****************************************
$testArray = array(1, 2, 3);
function testFunction($testArray)
{
    $result = 0;
    foreach ($testArray as $test) {
        $result += $test;
    }
    return $result;
}
$value = testFunction($testArray);
assert($value, 6);
//****************************************
$globalVar1 = 1;
function testGlobal()
{
    global $globalVar1;
    $localVar = 2;
    return $globalVar1 + $localVar;
}
assert(testGlobal(), 3);
testEnd();
 public function CommonAction()
 {
     echo testFunction();
 }
 function testFunction2()
 {
     return testFunction();
 }