aashcool198 Posted May 29, 2009 Share Posted May 29, 2009 I have made a page in html. now i want to display things using php scrip. Do i have to echo whole html code? if yes than do i have to put backslash before every double quote character of html code? Link to comment https://forums.phpfreaks.com/topic/160156-solved-embed-html-code-in-php-script/ Share on other sites More sharing options...
gevans Posted May 29, 2009 Share Posted May 29, 2009 you can just get the content $html = file_get_content("dir_to_file/file.html"); echo $html; Link to comment https://forums.phpfreaks.com/topic/160156-solved-embed-html-code-in-php-script/#findComment-844983 Share on other sites More sharing options...
aashcool198 Posted May 29, 2009 Author Share Posted May 29, 2009 No.. i want to publish the php script results on specified places in html page. Link to comment https://forums.phpfreaks.com/topic/160156-solved-embed-html-code-in-php-script/#findComment-845007 Share on other sites More sharing options...
gevans Posted May 29, 2009 Share Posted May 29, 2009 Now you're getting into template territory..... example (very basic and not best practice) the html file (content.html) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <base href="{BASE_HREF}" /> <!-- META DATA --> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="title" content="{PAGE_TITLE}" /> <meta name="keywords" content="{KEYWORDS}" /> <!-- FAVICON --> <link rel="icon" href="favicon.ico" type="image/vnd.microsoft.icon" /> <link rel="shortcut icon" href="favicon.ico" type="image/vnd.microsoft.icon" /> <!-- STYLESHEETS --> <style type="text/css" media="screen"> /* <![CDATA[ */ @import url(static/css/default.css); /* ]]> */ </style> <!--[if lte IE 7]> <link rel="stylesheet" type="text/css" href="static/css/IE/IE.css" /> <![endif]--> <!--[if IE 6]> <link rel="stylesheet" type="text/css" href="static/css/IE/IE6.css" /> <![endif]--> <!-- JAVASCRIPT FILES --> {JS} <title>{PAGE_TITLE}</title> </head> <body> <!-- I haven't done this bit, above is enough --> </body> </html> the php file (index.php) <?php $html = file_get_content("content.html"); $replaceThis = array('{BASE_HREF}', '{PAGE_TITLE}', '{KEYWORDS}', '{JS}'); $replaceWith = array('http://www.example.com/', 'A test page', 'keyword1, keyword2','<script type="text/javascript" src="a-javascript-file.js></script>"'); $html = str_replace($replaceThis, $replaceWith, $html); echo $html; I just wrote that quick, but you get the idea Link to comment https://forums.phpfreaks.com/topic/160156-solved-embed-html-code-in-php-script/#findComment-845075 Share on other sites More sharing options...
aashcool198 Posted May 30, 2009 Author Share Posted May 30, 2009 hey thanks! it was a complete new thing you taught me.. Link to comment https://forums.phpfreaks.com/topic/160156-solved-embed-html-code-in-php-script/#findComment-845846 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.