Hi, Dear all i am not too good in PHP but have one query to get solved, Please help Is it possible to have a HTML index page named index.html and call PHP functions in that HTML coded page For example : I keep my home page as index.html and now can i call a php code in that HTML code to display something. Like my page is pure HTML and i want to display the blog post on the HTML index page below my HTML design Is there way that I design a HTML page with nice looks and then in that page some where in corner I call PHP function to display my blog posts only by calling PHP function Please help
You cannot put PHP in HTML pages. The PHP interpreter will not parse it and it will come out as plain text. Instead, save your file as index.php - then you can place PHP in the HTML as follows: <html> <head> <title>PHP in HTML</title> </head> <body> Today's date is <? print date("m d, Y"); ?> </body> </html> Code (markup):
Ok understood but my requirement is that i need the files as index.html Because i have a website which is already up and running and it has all the files as .html and now i want to add blog on home page only where i can have some posts via blog. The reason is , I have PR3 for index.html file or domain So if i change it to .php, will it affect my PR ???
Incorrect. Providing your server is using Apache (which it likely is) then you can place the following in your .htaccess file:- AddType application/x-httpd-php .html Code (markup):
By default, PHP doesn't look in HTML files to parse PHP. Your method is technically correct, but generally speaking PHP does not parse HTML - therefore i'm not incorrect You could also rewrite your URLs if you really wanted to to mask the .php extension. Though Clarky's solution works well also.
Open apache's httpd.conf file,find "DirectoryIndex" and make index.php befor index.html . such as :"DirectoryIndex index.php index.php3 index.html index.htm" then you can access the index.php file by your domain ,no need include index.php