alternative-syntax testfile.
--POST--
--GET--
--FILE--
-<?php $a=1;
- while($a<10):
+<?php
+$a=1;
+while ($a<10) {
echo $a;
$a++;
- endwhile?>
+}
+?>
--EXPECT--
123456789
--POST--
--GET--
--FILE--
-<?php $a=1;
- switch($a):
- case 0;
+<?php
+$a=1;
+switch($a) {
+ case 0:
echo "bad";
break;
- case 1;
+ case 1:
echo "good";
break;
- default;
+ default:
echo "bad";
break;
- endswitch?>
+}
+?>
--EXPECT--
good
--POST--
--GET--
--FILE--
-<?php $a=1;
- if($a==0):
+<?php
+$a=1;
+if($a==0) {
echo "bad";
- else:
+} else {
echo "good";
- endif?>
+}
+?>
--EXPECT--
good
--POST--
--GET--
--FILE--
-<?php $a=1;
- if($a==0):
+<?php
+$a=1;
+
+if($a==0) {
echo "bad";
- elseif($a==3):
+} elseif($a==3) {
echo "bad";
- else:
+} else {
echo "good";
- endif?>
+}
+?>
--EXPECT--
good
--POST--
--GET--
--FILE--
-<?php $a=1; $b=2;
- if($a==0):
+<?php
+$a=1;
+$b=2;
+
+if($a==0) {
echo "bad";
- elseif($a==3):
+} elseif($a==3) {
echo "bad";
- else:
- if($b==1):
+} else {
+ if($b==1) {
echo "bad";
- elseif($b==2):
+ } elseif($b==2) {
echo "good";
- else:
+ } else {
echo "bad";
- endif;
- endif?>
+ }
+}
+?>
--EXPECT--
good
--POST--
--GET--
--FILE--
-<?php error_reporting(0);
- $a = 10;
- function Test()
- {
- static $a=1;
- global $b;
- $c = 1;
- $b = 5;
- echo "$a $b ";
- $a++;
- $c++;
- echo "$a $c ";
- }
- Test();
- echo "$a $b $c ";
- Test();
- echo "$a $b $c ";
- Test()?>
+<?php
+error_reporting(0);
+$a = 10;
+
+function Test()
+{
+ static $a=1;
+ global $b;
+ $c = 1;
+ $b = 5;
+ echo "$a $b ";
+ $a++;
+ $c++;
+ echo "$a $c ";
+}
+
+Test();
+echo "$a $b $c ";
+Test();
+echo "$a $b $c ";
+Test();
+?>
--EXPECT--
1 5 2 2 10 5 2 5 3 2 10 5 3 5 4 2
--POST--
--GET--
--FILE--
-<?php Function Test()
- {
- static $a=1;
+<?php
- echo "$a ";
- $a++;
- if($a<10): Test(); endif;
- }
- Test()?>
+function Test()
+{
+ static $a=1;
+ echo "$a ";
+ $a++;
+ if($a<10): Test(); endif;
+}
+
+Test();
+
+?>
--EXPECT--
1 2 3 4 5 6 7 8 9
--POST--
--GET--
--FILE--
-<?php old_function Test $a,$b (
- echo $a+$b;
- );
- Test(1,2)?>
+<?php
+function test ($a,$b) {
+ echo $a+$b;
+}
+test(1,2);
+?>
--EXPECT--
3
--POST--
--GET--
--FILE--
-<?php old_function Test $b (
- $b++;
- return($b);
- );
- $a = Test(1);
- echo $a?>
+<?php
+function test ($b) {
+ $b++;
+ return($b);
+}
+$a = test(1);
+echo $a;
+?>
--EXPECT--
2
--GET--
--FILE--
<?php
-old_function F (
- if(1):
+function F () {
+ if(1) {
return("Hello");
- endif;
-);
+ }
+}
$i=0;
-while($i<2):
+while ($i<2) {
echo F();
$i++;
-endwhile;
+}
?>
--EXPECT--
HelloHello
--GET--
--FILE--
<?php
- error_reporting(0);
- $a="echo \"Hello\";";
- eval($a);
+error_reporting(0);
+$a="echo \"Hello\";";
+eval($a);
?>
--EXPECT--
Hello
--GET--
--FILE--
<?php
-old_function F $a (
+function F ($a) {
eval($a);
-);
+}
error_reporting(0);
F("echo \"Hello\";");
--POST--
--GET--
--FILE--
-<?php
- include "015.inc";
+<?php
+include "015.inc";
?>
--EXPECT--
Hello
<?php
- old_function MyFunc $a (
- echo $a;
- );
+function MyFunc ($a) {
+ echo $a;
+}
?>
--GET--
--FILE--
<?php
- include "016.inc";
- MyFunc("Hello");
+include "016.inc";
+MyFunc("Hello");
?>
--EXPECT--
Hello
--POST--
--GET--
--FILE--
-<?php $a = 1;
-old_function Test $a (
- if($a<3):
+<?php
+$a = 1;
+function Test ($a) {
+ if ($a<3) {
return(3);
- endif;
-);
+ }
+}
-if($a < Test($a)):
+if ($a < Test($a)) {
echo "$a\n";
$a++;
-endif?>
+}
+?>
--EXPECT--
1
function switchtest ($i, $j)
{
- switch ($i):
+ switch ($i) {
case 0:
switch($j) {
case 0:
break;
default:
echo "Default taken\n";
- endswitch;
+ }
}
for ($i=0; $i<3; $i++) {
for ($k=0; $k<10; $k++) {
--GET--
--FILE--
<?php
-old_function RekTest $nr (
-
-echo " $nr ";
-
-
-$j=$nr+1;
-while ($j < 10)
-{
- echo " a ";
- RekTest($j);
- $j++;
- echo " b $j ";
-};
-echo "\n";
-
-
-
-);
+function RekTest ($nr) {
+ echo " $nr ";
+ $j=$nr+1;
+ while ($j < 10) {
+ echo " a ";
+ RekTest($j);
+ $j++;
+ echo " b $j ";
+ }
+ echo "\n";
+}
RekTest(0);
?>
<?php
class obj {
function method() {}
- }
-
-function test($o_copy) {
- $o_copy->root->set_in_copied_o=TRUE;
- var_dump($o_copy);?><BR><?php }
+}
$o->root=new obj();
function foo($name) {
$GLOBALS['List']= &$this;
$this->Name = $name;
- $GLOBALS['List']->echoName(); }
+ $GLOBALS['List']->echoName();
+ }
function echoName() {
- $GLOBALS['names'][]=$this->Name; } }
+ $GLOBALS['names'][]=$this->Name;
+ }
+}
-function &foo2(&$foo) {
- return $foo; }
+function &foo2(&$foo) {
+ return $foo;
+}
$bar1 =& new foo('constructor');
$List->echoName();
-print ($names==array('constructor','outside','outside','constructor','outside','outside')) ? 'success':'failure'; ?>
+print ($names==array('constructor','outside','outside','constructor','outside','outside')) ? 'success':'failure';
+?>
--EXPECT--
-success
\ No newline at end of file
+success
--FILE--
<?php
// reported by php.net@alienbill.com
- $outsidearray = array("key1","key2");
- $insidearray = array("0","1");
+$outsidearray = array("key1","key2");
+$insidearray = array("0","1");
- while(list(,$outerval) = each($outsidearray)){
- $placeholder = $insidearray;
- while(list(,$innerval) = each($insidearray)){
- print "inloop $innerval for $outerval\n";
- }
- }
+while(list(,$outerval) = each($outsidearray)){
+ $placeholder = $insidearray;
+ while(list(,$innerval) = each($insidearray)){
+ print "inloop $innerval for $outerval\n";
+ }
+}
?>
--EXPECT--
inloop 0 for key1
inloop 1 for key1
-
--- /dev/null
+--TEST--
+Alternative syntaxes test
+--POST--
+--GET--
+--FILE--
+<?php
+$a = 1;
+
+echo "If: ";
+if ($a) echo 1; else echo 0;
+if ($a):
+ echo 1;
+else:
+ echo 0;
+endif;
+
+echo "\nWhile: ";
+while ($a<5) echo $a++;
+while ($a<9):
+ echo ++$a;
+endwhile;
+
+echo "\nFor: ";
+for($a=0;$a<5;$a++) echo $a;
+for($a=0;$a<5;$a++):
+ echo $a;
+endfor;
+
+echo "\nSwitch: ";
+switch ($a):
+ case 0;
+ echo 0;
+ break;
+ case 5:
+ echo 1;
+ break;
+ default;
+ echo 0;
+ break;
+endswitch;
+
+echo "\nold_function: ";
+old_function foo $bar, $baz (
+ return sprintf("foo(%s, %s);\n", $bar, $baz);
+);
+echo foo(1,2);
+?>
+--EXPECT--
+If: 11
+While: 12346789
+For: 0123401234
+Switch: 1
+old_function: foo(1, 2);