fork download
  1. /* main module */
  2. ?php>
  3. <!doctype html>
  4. <html lang="en">
  5. <head>
  6. <meta charset="UTF-8">
  7.  
  8. <link rel="stylesheet" href= "css/ReadingFile-4.css" type = "text/css"/>
  9.  
  10. <title>A Title</title>
  11. </head>
  12. <body>
  13. <div id="dev-1" >
  14. <?php include "include/phpFunctionDefs.php";?>
  15. <form method="get" id="f1">
  16. <?php include "include/phpFunctionCalls.php";?>
  17. </form>
  18. </div>
  19.  
  20. <div id="dev-2">
  21. <form method="get" id = "f2">
  22. </form>
  23. </div>
  24.  
  25.  
  26.  
  27. </body>
  28. </html>
  29. ?>
  30.  
  31. // your code goes here
  32.  
  33. /* include/phpFunctionCalls.php
  34. <?php
  35. addTextBox("First Name", 1);
  36. addTextBox("Surname", 2);
  37. addCombo("cities.txt", 3, "City");
  38. ?>
  39.  
  40. */
  41. /*
  42. include/phpFunctionDefs.php
  43. <?php
  44.  
  45. function addTextBox($lb, $tb)
  46. {
  47. echo "\n\t\t<label id='lb$tb'>$lb</label>";
  48. echo "\n\t\t<input id='tb$tb' type='text'/>\n";
  49. }
  50.  
  51. function addCombo($cities, $lb, $lbtxt)
  52. {
  53. $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
  54. $filename = $DOCUMENT_ROOT."/udemy/data/".$cities;
  55. $lines_in_file = count(file($filename));
  56. $fp = fopen($filename, "rt");
  57. echo "\n\t\t<label id='lb$lb'>$lbtxt</label>";
  58. echo "\n\n\t\t<select id='cities'>" ;
  59. for ($i = 1; $i <= $lines_in_file; ++$i) {
  60. $line = trim(fgets($fp));
  61. echo "\n\t\t\t<option id='$line'>".$line."</option>";
  62. }
  63. fclose($fp);
  64. echo "\n\t\t</select><br>\n";
  65. }
  66. ?>
  67.  
  68. */
  69. */
  70. /*
  71. // data/cities.txt file
  72. Chicago
  73. Detroit
  74. Toronto
  75. LA
  76.  
  77. */
Success #stdin #stdout #stderr 0.02s 24580KB
stdin
Standard input is empty
stdout
/* main module */
?php>
<!doctype html> 
<html lang="en">
  <head>
  <meta charset="UTF-8">

    <link rel="stylesheet"    href= "css/ReadingFile-4.css" type = "text/css"/>

    <title>A Title</title>
  </head>
  <body>
    <div id="dev-1" >
            <form method="get" id="f1">
              </form>
    </div>

    <div id="dev-2">
      <form method="get" id = "f2">
      </form>
    </div>
    
    

  </body>
  </html>
?>

// your code goes here

/* include/phpFunctionCalls.php

		<label id='lb1'>First Name</label>
		<input id='tb1' type='text'/>

		<label id='lb2'>Surname</label>
		<input id='tb2' type='text'/>

		<label id='lb3'>City</label>

		<select id='cities'>
			<option id=''></option>
		</select><br>

*/
/*
	include/phpFunctionDefs.php
	
	*/	
*/
/*
// data/cities.txt file
Chicago
Detroit
Toronto
LA

*/
stderr
PHP Warning:  include(include/phpFunctionDefs.php): failed to open stream: No such file or directory in /home/W1amU4/prog.php on line 14
PHP Warning:  include(): Failed opening 'include/phpFunctionDefs.php' for inclusion (include_path='.:/usr/share/php') in /home/W1amU4/prog.php on line 14
PHP Warning:  include(include/phpFunctionCalls.php): failed to open stream: No such file or directory in /home/W1amU4/prog.php on line 16
PHP Warning:  include(): Failed opening 'include/phpFunctionCalls.php' for inclusion (include_path='.:/usr/share/php') in /home/W1amU4/prog.php on line 16
PHP Warning:  file(/udemy/data/cities.txt): failed to open stream: No such file or directory in /home/W1amU4/prog.php on line 55
PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /home/W1amU4/prog.php on line 55
PHP Warning:  fopen(/udemy/data/cities.txt): failed to open stream: No such file or directory in /home/W1amU4/prog.php on line 56
PHP Warning:  fgets() expects parameter 1 to be resource, bool given in /home/W1amU4/prog.php on line 60
PHP Warning:  fclose() expects parameter 1 to be resource, bool given in /home/W1amU4/prog.php on line 63