javascript - Can't use document.write more than one time in PHP -
here html , call external php
<!doctype html> <html> <body> <h1>my first heading</h1> <script src="index.php"></script> <p>my first paragraph.</p> </body> </html> and php script
<? $strfilename = "poom.bis"; $objfopen = fopen($strfilename, 'r'); if ($objfopen) { while (!feof($objfopen)) { $file = fgets($objfopen, 4096); // echo $file; echo "document.writeln('$file'+);"; } fclose($objfopen); } $test = "hello world"; echo "document.writeln( '<ul>'+ '<li>.$test.</li>'+ '<li>test2</li>'+ '<li>test3</li>'+ '</ul>' );"; ?> it error when using document.write more 1 time
what should solve problem
please advice
ps. use echo "document.writeln('$file'+);"; 1 time there no error , show result
first error: line
echo "document.writeln('$file'+);"; should be
echo "document.writeln('$file');"; (without plus sign). make sure file poom.bis doesn't contain newline, not @ end. if does, have strip them away (trim()).
second error was (until edited it) use of document.writein (which doesn't exist) instead of document.writeln (which does).
tested , works.
also, while i'm @ it, since asked advice how solve problem: @ browser's error console , try debug it.
Comments
Post a Comment