2019-05-06 06:39:36 +02:00
|
|
|
class Test {
|
|
|
|
|
2019-05-17 08:40:41 +02:00
|
|
|
public void goto_test1() {
|
2019-05-06 06:39:36 +02:00
|
|
|
int $i = 0;
|
|
|
|
a:
|
|
|
|
print("Foo $i\n");
|
|
|
|
if($i > 5)
|
|
|
|
goto b;
|
|
|
|
$i++;
|
|
|
|
goto a;
|
|
|
|
b:
|
|
|
|
print("Bar $i\n\n");
|
|
|
|
}
|
|
|
|
|
2019-05-17 08:40:41 +02:00
|
|
|
public void goto_test2(int $a = 2) {
|
2019-05-06 06:39:36 +02:00
|
|
|
switch($a) {
|
|
|
|
case 1:
|
|
|
|
print("\$a is 1\n\n");
|
|
|
|
goto out;
|
|
|
|
case 2:
|
|
|
|
print("\$a is 2\n\n");
|
|
|
|
goto out;
|
|
|
|
case 3:
|
|
|
|
print("\$a is 3\n\n");
|
|
|
|
goto out;
|
|
|
|
case 4:
|
|
|
|
print("\$a is 4\n\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
}
|
|
|
|
|
2019-05-17 08:40:41 +02:00
|
|
|
public void goto_test3() {
|
2019-05-06 06:39:36 +02:00
|
|
|
int $a = 10;
|
|
|
|
a:
|
|
|
|
$a--;
|
|
|
|
print("$a\n");
|
|
|
|
if($a > 5) {
|
|
|
|
goto a;
|
|
|
|
}
|
|
|
|
print("\n");
|
|
|
|
}
|
|
|
|
|
2019-05-17 08:40:41 +02:00
|
|
|
public void goto_test4() {
|
2019-05-06 06:39:36 +02:00
|
|
|
string[] $headers = {'subject', 'bcc', 'to', 'cc', 'date', 'sender'};
|
|
|
|
int $pos = 0;
|
|
|
|
int $c;
|
|
|
|
hIterator: {
|
|
|
|
$c = 0;
|
|
|
|
print($headers[$pos], "\n");
|
|
|
|
cIterator: {
|
|
|
|
print(" ", $headers[$pos][$c], "\n");
|
|
|
|
if(!($headers[$pos][++$c])) {
|
|
|
|
goto cIteratorExit;
|
|
|
|
}
|
|
|
|
goto cIterator;
|
|
|
|
}
|
|
|
|
cIteratorExit: {
|
|
|
|
if($headers[++$pos]) {
|
|
|
|
goto hIterator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Program {
|
|
|
|
private object $test;
|
|
|
|
|
2019-05-17 08:40:41 +02:00
|
|
|
public void __construct() {
|
2019-05-06 06:39:36 +02:00
|
|
|
$this->test = new Test();
|
|
|
|
}
|
|
|
|
|
2019-05-17 08:40:41 +02:00
|
|
|
public void main() {
|
2019-05-06 06:39:36 +02:00
|
|
|
$this->test->goto_test1();
|
|
|
|
$this->test->goto_test2();
|
|
|
|
$this->test->goto_test3();
|
|
|
|
$this->test->goto_test4();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|