User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 363,779 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,548 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Sep 20th, 2004
Views: 2,231
I got bored and started some scripting the other day in PHP, this is just a sample that i wrote, just uncomment the part of script that you would like to see. IE remove the /* and */ around a certain area. i know its not great, but some beginners might find this a little helpful.
php Syntax | 1 stars
  1. <?php
  2. /////////////////////////////////////////////////////
  3. //Block of code is testing for a switch, to view ////
  4. //the test just remove the /* and */ and the ////////
  5. //begining and ending of this code block/////////////
  6. /////////////////////////////////////////////////////
  7. /*
  8.  
  9. echo "The expression x <= 3 while x=1 is to be evaluated <br />";
  10. echo "The values of x are to be printed using a case switch <br />";
  11. for($x = 1; $x <= 3; $x++)
  12. {
  13.  
  14. switch ($x)
  15. {
  16. case 1:
  17. echo "Number is ";
  18. echo $x;
  19. echo "<br />";
  20. break;
  21. case 2:
  22. echo "Number is ";
  23. echo $x;
  24. echo "<br />";
  25. break;
  26. case 3:
  27. echo "Number is ";
  28. echo $x;
  29. echo "<br />";
  30. break;
  31. default:
  32. echo "Numbers is not between 1 and 3 <br />";
  33. break;
  34. }
  35.  
  36.  
  37. }
  38. */
  39.  
  40. /*
  41. /////////////////////////////////////////////////
  42. //Will print the vallues of a given array////////
  43. /////////////////////////////////////////////////
  44. $arr=array("one", "two", "three");
  45.  
  46. foreach ($arr as $value)
  47. echo "Value: " . $value . "<br />";
  48. */
  49.  
  50.  
  51. /////////////////////////////////////////////////
  52. //Code to output where the user came from and////
  53. //The IP along with their Browser Version////////
  54. /////////////////////////////////////////////////
  55.  
  56. /*
  57. echo "Referer: " . $_SERVER['HTTP_REFERER'] . "<br />";
  58. echo "Browser: " . $_SERVER['HTTP_USER_AGENT'] . "<br />";
  59. echo "IP Add: " . $_SERVER['REMOTE_ADDR'] . "<br />";
  60. */
  61. //////////////////////////////////////////////////
  62. //Testing the fopen() function////////////////////
  63. //////////////////////////////////////////////////
  64. /*
  65. $f=fopen ("welcome.txt","r+");
  66. */
  67. /*
  68. if (!($f=fopen("welcomez.txt","r")))
  69. exit ("unable to open file!");
  70. */
  71. ?>
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 10:40 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC