sample.php.txt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // The next line contains a syntax error:
  3. if () {
  4. return "The parser recovers from this type of syntax error";
  5. }
  6. ?>
  7. <html>
  8. <head>
  9. <title>Example page</title>
  10. </head>
  11. <body>
  12. <script type="text/javascript">
  13. // Some PHP embedded inside JS
  14. // Generated <?=date('l, F jS, Y')?>
  15. var server_token = <?=rand(5, 10000)?>
  16. if (typeof server_token === 'number') {
  17. alert('token: ' + server_token);
  18. }
  19. </script>
  20. <div>
  21. Hello
  22. <? if (isset($user)) { ?>
  23. <b><?=$user?></b>
  24. <? } else { ?>
  25. <i>guest</i>
  26. <? } ?>
  27. !
  28. </div>
  29. <?php
  30. /* Example PHP file
  31. multiline comment
  32. */
  33. $cards = array("ah", "ac", "ad", "as",
  34. "2h", "2c", "2d", "2s",
  35. "3h", "3c", "3d", "3s",
  36. "4h", "4c", "4d", "4s",
  37. "5h", "5c", "5d", "5s",
  38. "6h", "6c", "6d", "6s",
  39. "7h", "7c", "7d", "7s",
  40. "8h", "8c", "8d", "8s",
  41. "9h", "9c", "9d", "9s",
  42. "th", "tc", "td", "ts",
  43. "jh", "jc", "jd", "js",
  44. "qh", "qc", "qd", "qs",
  45. "kh", "kc", "kd", "ks");
  46. srand(time());
  47. for($i = 0; $i < 52; $i++) {
  48. $count = count($cards);
  49. $random = (rand()%$count);
  50. if($cards[$random] == "") {
  51. $i--;
  52. } else {
  53. $deck[] = $cards[$random];
  54. $cards[$random] = "";
  55. }
  56. }
  57. srand(time());
  58. $starting_point = (rand()%51);
  59. print("Starting point for cut cards is: $starting_point<p>");
  60. // display shuffled cards (EXAMPLE ONLY)
  61. for ($index = 0; $index < 52; $index++) {
  62. if ($starting_point == 52) { $starting_point = 0; }
  63. print("Uncut Point: <strong>$deck[$index]</strong> ");
  64. print("Starting Point: <strong>$deck[$starting_point]</strong><br>");
  65. $starting_point++;
  66. }
  67. ?>
  68. </body>
  69. </html>