LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   get php to print html doc line by line - mine is all one string (https://www.linuxquestions.org/questions/programming-9/get-php-to-print-html-doc-line-by-line-mine-is-all-one-string-4175665582/)

pizzipie 12-07-2019 07:32 PM

get php to print html doc line by line - mine is all one string
 
Just beginning to try to create a PHP form generator. Php ends up producing all one string.

Code:

<?php
set_include_path( '../../include' );
error_reporting (E_ALL ^ E_NOTICE);

$str=<<<eot

&lt!DOCTYPE html&gt

&lthtml&gt

&lthead&gt

&ltmeta http-equiv="content-type" content="text/html; charset=UTF-8" /&gt`
       
&lttitle&gtCreate phpadmin() style SQL box - using dynamic html creation &lt/title&gt

&lt!-- ============== styles  ================ --&gt

&ltlink rel="stylesheet " type="text/css" href="css/query.css" /&gt

&lt!--  &ltlink rel="stylesheet " type="text/css" href="css/polly.css" /&gt  --&gt

&lt!-- ============== scripts1 ================ --&gt

&ltscript  type="text/javascript" src="../../jquery/jquery-2.1.1.js"&gt&lt/script&gt
&ltscript type="text/javascript" src="insertAtCaret.js"&gt&lt/script&gt
&ltscript type="text/javascript" src="connect.js"&gt&lt/script&gt

Result

Code:

<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" />` <title>Create phpadmin() style SQL box - using dynamic html creation </title> <!-- ============== styles ================ --> <link rel="stylesheet " type="text/css" href="css/query.css" /> <!-- <link rel="stylesheet " type="text/css" href="css/polly.css" /> --> <!-- ============== scripts1 ================ --> <script type="text/javascript" src="../../jquery/jquery-2.1.1.js"></script> <script type="text/javascript" src="insertAtCaret.js"></script> <script type="text/javascript" src="connect.js">

dogpatch 12-07-2019 08:08 PM

If you are outputting to a text file, append '[ampersand]#10;' to each place you want a newline.

If outputting to a web document, append '&lt;br&gt;'

NOTE TO JEREMY:
How can i get an ampersand to print in my first line? (See this thread)

NevemTeve 12-07-2019 10:56 PM

(Made some tests with & symbols, their behaviour seems to be a bit inconsistent, specially after editing the post)

dogpatch 12-08-2019 08:40 AM

OK, back to the OP's question:

If you are outputting to a text file, append
Code:

&#10;
to each place you want a newline.

If outputting to a web document, append
Code:

&lt;br&gt;
You shoud also probably terminate your ampersand tags with a semicolon, thus
Code:

&lt;
-------------
(Thanks to pan64 in this thread for advice in printing an ampersand in an LQ post)

pizzipie 12-08-2019 02:27 PM

Thanks very much folks!!

R


All times are GMT -5. The time now is 10:25 AM.