Computer tools > PHP

PHP

Summary

Hello_World.php

<!DOCTYPE html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <link rel="shortcut icon" type="image/x-icon" href="images/logo.ico">
  <style>
    body {
      font-family:arial;
    }
  </style>
  <script>
  </script>
</head>
<body>
  <Title>PHP</Title>
  <?php
    echo "Hello World\n";
  ?>
</body>
</html>
Result: Hello_World.php page with the following content:
<!DOCTYPE html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <link rel="shortcut icon" type="image/x-icon" href="images/logo.ico">
  <style>
    body {
      font-family:arial;
    }
  </style>
  <script>
  </script>
</head>
<body>
  <Title>PHP</Title>
  Hello World
</body>
</html>

page_visits.php

Writes number of page visits in the file “page_visits.txt” (which needs writing permission)
<?php
$page_visits_file = ("page_visits.txt");
$page_visits = file($page_visits_file);
$page_visits[0]++;
$fp = fopen($page_visits_file, "w");
fputs($fp, "$page_visits[0]");
fclose($fp);
?>