Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone please explain this php behavior?

Status
Not open for further replies.

BobMCT

IS-IT--Management
Sep 11, 2000
756
US
In the interest of standardization on xhtml transitional I've thought of putting the DOCTYPE required statements in an external module and include them in my php programs.

Heres the content of module _doctype.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"<html xmlns="<!--***********************************************************************-->


OK - that said, here's how I include it in my programs:

.
.
session_start();
include_once("_doctype.php");
.
.

This appears to work just fine. My question concerns this: I DON'T OUTPUT this at all. Originally my included module contained $DOCTYPE="<blah blah>"; and in my output I used print $DOCTYPE; but that was causing errors. Research showed that the output was including the "$DOCTYPE=" literal as well.

I therefore removed this operative.

Again, the ONLY reference in the program is the include_once of the module. No physical command to output it at all. However, the multitude of pages that this program creates all seem to work just fine! Go figure.

Can someone perhaps please explain why this works? I can guess but I would rather not. I would rather understand why!

Thanks,
 
not sure if I understand your question, but here I go and try and put my $0.02.

in the "_doctype.php" did you do this

Code:
<?
$doctype="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
    	\"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">[/URL]
		<html xmlns=\"[URL unfurl="true"]http://www.w3.org/1999/xhtml\">";[/URL]
		
echo $doctype;
?>

or this [notice below has no delimiters, which is incorrect]

Code:
$doctype="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
    	\"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">[/URL]
		<html xmlns=\"[URL unfurl="true"]http://www.w3.org/1999/xhtml\">";[/URL]
		
echo $doctype;


... using include prints out any html code, thats why you dont need to echo it.
 
Ahhh!!! I didn't include the <?php ... ?> which rendered it html. That's why it was being output.

Thanks,

(brain-dead) Bob
 
glad I can help, we all have mental brain-farts every once in a while that keep you pounding your head against the keyboard, but the answer is right in front of you face
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top