How to use script tag of php in html file
Moderator: General Moderators
- jdhorton77
- Forum Commoner
- Posts: 56
- Joined: Tue Nov 07, 2006 3:29 pm
- Location: Charlotte, NC
How to use script tag of php in html file
I'm trying to come up with an index file that is html and I want to be able to use the php command of include. I know html has a tag called <script> that you can use for javascript along with php, but I'm not sure on how the syntax would go. Can someone give me a clue. Thanks.
Code: Select all
<script src="your/php/file.php"></script>- jdhorton77
- Forum Commoner
- Posts: 56
- Joined: Tue Nov 07, 2006 3:29 pm
- Location: Charlotte, NC
Ok, I tried what you said and it's not working for some reason. I have my path correct. Here is my code if it helps.
And thanks for the help.
Code: Select all
<td>
<script src="http://Somewhere.com/menu.php"></script>
</td>
- jdhorton77
- Forum Commoner
- Posts: 56
- Joined: Tue Nov 07, 2006 3:29 pm
- Location: Charlotte, NC
try the following..
The client-side of things (index.html):
The server-side of things (content.php):
This is a VERY simplified example to get you started with. You should probably look into dom-manipulation via Javascript or better yet the "buzzed up" AJAX-techniques.
The client-side of things (index.html):
Code: Select all
<html>
<head>
</head>
<body>
<script type="text/javascript" src="content.php">
</script>
</body>
</html>Code: Select all
<php
$content = '<h1>hello world!</h1>';
?>
document.write('<?php echo $content?>');