...

View Full Version : using php and html together



phpnewb
12-01-2006, 04:31 AM
I am using php and html in the same document. I am saving it as a .php. Do I still use the <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> even with php or is there a different heading.

Tyree
12-01-2006, 04:34 AM
PHP doesn't care what doctype you declare in the html. HTML, XHTML... doesn't matter. PHP is server-side, HTML is client-side.

phpnewb
12-01-2006, 01:57 PM
The problem is that my script seems to work just fine but none of my html is displayed, and I don't know why. Can apache only display the php or what? It is like it ignores my html.

phpnewb
12-01-2006, 11:45 PM
if there is anyone that can answer my question, the help would be much appreciated

CFMaBiSmAd
12-01-2006, 11:59 PM
If a request is made for a page that ends in .htm/html/txt... (non server side PHP/ASP/NET...) a web server basically reads the file and sends the content to the browser.

If a request is made for a .php file (assuming the web server is configured to pass .php files to the php parser - the exact extension does not matter, you could configure this to be .abc if you wanted) the PHP language parser is invoked to read the file and attempt to parse it. Any content that is not within php tags, is simply output to the browser. Content that is within php tags gets parsed and interpreted as php code.

When you mix HTML content and php code, so long as there are proper opening and closing php tags surrounding the php code, it will work.

PHP code sends output to the browser using echo/print/print_r statements. The end result that reaches the browser needs to be valid HTML code. Therefore, you need to output a doctype that matches the resultant HTML code.

If you have some specific code that is not working, you would need to post it.

phpnewb
12-02-2006, 03:54 AM
the scripting i was asking about is on this page
http://www.codingforums.com/showthread.php?t=101846&page=2

phpnewb
12-02-2006, 03:52 PM
thx the problem has been solved

114211
12-03-2006, 03:41 AM
PHP doesn't care what doctype you declare in the html. HTML, XHTML... doesn't matter. PHP is server-side, HTML is client-side.

that's what makes php so awesome! its flexibilty and robustness. I think that its because of this we've seen the explosion of the use of php in the recent few last years. wouldn't you agree? :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum