View Full Version : Insert php into html
Anyone know the code to insert php into html?
<html>
<head>
<title>
Php Example
</title>
<body>
<?php
echo("woww !! this php example works !!!");
?>
</body>
</html>
simple
you can put php anywhr on your page...but it shud be enclosed in <?php
and ?> tags.
you can even say something like this....
<a href="<?php echo("link.php") ?>" target="_blank">try this link </a> :D
well wot if i wanted to insert news? isnt it something like
<?php include("link.php") ?> ?
Nightfire
10-03-2002, 04:22 AM
Yeah, if the news is on link.php
laughbiz
10-03-2002, 06:09 AM
Don't forget, the pages you have PHP code in must have the suffix .php
------------------------------------------------------------------------------
www.laughland.biz
"the web site for web sites"
mordred
10-03-2002, 10:13 AM
Not necessarily.
That depends on the actual server configuration, you can configure the server in a way that he also puts .html, .htm, .whatever files through the PHP engine. But in most situations, the server is set up to accept at least .php files.
yeah I got it to work thanks alot everyone
actually any file can be included in your php page....and of you want it to contain php code....then it has to be in the normal php form...enclosed within those <?php ?> tags...I can well name it as news.inc, news.cq, or news.anything....it will work just the same :D
laughbiz
10-03-2002, 09:47 PM
Mordred, how do you configure the server to put all pages through the php engine?
laughbiz
10-03-2002, 09:56 PM
Originally posted by c q
actually any file can be included in your php page....and of you want it to contain php code....then it has to be in the normal php form...enclosed within those <?php ?> tags...I can well name it as news.inc, news.cq, or news.anything....it will work just the same :D
That is true, the include() can add any type of file to your php document. But any file containing php code must have a .php suffix unless, as Mordred has pointed out, the server is configured to put files with other suffixes through the php engine.
www.laughland.biz
"the web site for web sites"
mordred
10-03-2002, 09:56 PM
If you're running your site on Apache and your host permits it, you can have a .htaccess file in your document root with this setting:
AddType application/x-httpd-php .bar .foo .133t .guessWhat
And all files that have the extension .bar etc. get parsed by the PHP engine. Frankly, that's all I know about this issue, I'm not that good on tuning servers, so I can't provide you with any more details, but google should give you references to plenty of information.
mordred
10-03-2002, 10:03 PM
Originally posted by laughbiz
That is true, the include() can add any type of file to your php document. But any file containing php code must have a .php suffix unless, as Mordred has pointed out, the server is configured to put files with other suffixes through the php engine.
;) You are again slightly wrong; what you said is only true if you include() the file through HTTP. If you include it from your local filesystem, like include('test.inc"), all code within the <?php tags is evaluated, regardless of the file's extension.
http://www.php.net/manual/en/function.include.php
Nightfire
10-04-2002, 12:48 PM
mordred's right :) I've got my personal site just running from txt includes :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.