Forum Moderators: coopster
Using your typical HTML " doesn't work because it throws in backslashes for some reason. I'm trying to create the include to echo the right characters as needed but am having some difficulties. Please take a look at the include and maybe you can see what I'm doing wrong. Thanks in advance for any help.
<?php
echo '!DOCTYPE HTML PUBLIC'; echo '"'; echo'-//W3C//DTD HTML 4.01//EN'; echo '"';\n
echo 'http://www.w3.org/TR/html4/strict.dtd'; echo '"';
?>
echo "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/ strict.dtd'>";
Also see the PHP [php.net] manual and read about addslashes() [php.net], stripslashes() [php.net], htmlspecialchars() [php.net] and quotemeta() [php.net].
Have fun ;)
If an include isn't the right way to go about this (I'm pretty sure it is) then please tell me.
<td class="left"><select class="textbar" name="dtd">
<option value="<? include ("loose.inc")?>">Transitional</option>
<option value="<? include ("strict.inc")?>">Strict</option>
<option value="<? include ("frameset.inc")?>">Frameset</option>
</select></td>
On submit the correct DTD is put in plain text on a new page. All the other elements of the form work it's just getting all the characters of a DTD to work.
I really do appreciate all the help.
<option value="<?=$html4?>">Transitional</option>
If you want the doctype actually readable as html then it's simply:
printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">')
P'raps you could re-explain the problem you are having, as as I understand it I don't see an issue?
asp
<?php
include 'show_doctype.php';
?>
And then make this as show_doctype.php file:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Thats it. No other code needed. The doctype will be printed literally on the page. If you want to show different doctypes according so some logic, use switches or if's
But I don't understand what you mean by "text". If you mean you want the browser to render the doctype it as normal text in a webpage, then...
As I've said > and < does not work in PHP. If it did this issue would be solved.
procedually generating <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> as discussed via printf() does work fine.
If you want the doctype to be rendered as part of a parsable html document then again the solution has already been presented.
If you want to show the entire contents of the strict DTD as if you had typed: [w3.org ] into you web browser, then that's nothing to do with PHP, the server is probably configured to send the mime type as either text/plain or text/xml. Once you attempt to embed that content inside HTML tags it becomes html as far as the browser is concered, and thus will be rendered as such.
If you are content to render the above doc from your local server rather than the above discussed URL then just load the text of the doc into a variable (use fopen()) and use printf() again.
asp
Came from:
<?php
printf (<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">)
?>
But that is pretty much what I want to do. Generate the doctype as plain text on a web page.
printf (<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">)
Firstly You haven't converted the " to the html entity "
Secondly the printf() string is encapsulated by quotes.
In your case as you have nothing to evaluate inside the quotes you would use ' instead of "
Thus:
printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/html4/strict.dtd">') asp