Guest User

Untitled

a guest
Aug 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <html>
  2. <head><title>About Us Page</title></head>
  3. <?php
  4. $file_name= "loremIpsum.txt";
  5. $pagetitle = "About Us WebPage ";
  6. if(file_exists($file_name))
  7. {
  8. //open file for writng and place pointer at the end
  9. $handle = fopen($file_name, 'a+');
  10.  
  11. if(!$handle)
  12. {
  13. die("couldn't open file <i>$file_name</i>");
  14. }
  15.  
  16. fputs($handle, $pagetitle . "\n" . date("Y/m/d") );
  17. echo "success writing to file";
  18. }
  19. else
  20. {
  21. echo "file <i>$file_name</i> doesn't exists";
  22. }
  23. fclose($handle);
  24. ?>
  25.  
  26. <body>
  27. <h1>About Us</h1>
  28. <a href="home.php">Home Page</a>
  29. <a href="about.php">About Us</a>
  30. <a href="contact.php">Contact Us</a>
  31.  
  32.  
  33.  
  34. <?php
  35. $lines = 0;
  36.  
  37. if ($fh = fopen('loremIpsum.txt', 'r')) {
  38. while (!feof($fh)) {
  39. if (fgets($fh)) {
  40. $lines++;
  41. }
  42. }
  43. }
  44. echo $lines; // line count
  45. ?>
  46.  
  47. </body>
  48. </html>
Add Comment
Please, Sign In to add comment