Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

<?

php

echo "Hello World!";

?>

<?php

echo "Tomorrow I'll learn PHP global variables." . "\n";

echo "This is a bad command : del c:\\*.*" . "\n";

?>

<?php

function test($x, $y)

return $x == $y ? ($x + $y)*3 : $x + $y;

echo test(1, 2) . "\n";

echo test(3, 2) . "\n";

echo test(2, 2) . "\n";

?>
<?php

function test($n)

$x = 51;

if ($n > $x)

return ($n - $x) * 3;

return $x - $n;

echo test(53) . "\n";

echo test(30) . "\n";

echo test(51) . "\n";

?>

<?php

function test($x, $y)

return ($x == 30) || ($y == 30) || ($x + $y == 30);

var_dump(test(30, 0));

var_dump(test(25, 5));

var_dump(test(20, 30));

var_dump(test(20, 25));

?>
<?php

function test($s)

if (strlen($s) >= 2 && substr($s, 0, 2) == "if")

return $s;

return "if " . $s;

echo test("if else") . "\n";

echo test("else") . "\n";

echo test("if") . "\n";

?>

You might also like