2

I have a basic HTML page with some JavaScript code on it, and when I try to put any PHP code in the body, it reads it as a comment.

<html>
    <head>
        <link rel="stylesheet" href="style.css" type="text/css" media="screen">
        <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
        <script type="text/javascript" src="jquery.tablesorter.min.js"></script>
        <script type="text/javascript" src="jquery.tablesorter.pager.js"></script>
        <script type="text/javascript">
            $(function() {
                $("table")
                .tablesorter({widthFixed: true, widgets: ['zebra']})
                .tablesorterPager({container: $("#pager")});
            });
        </script>
    </head>

    <body>
        <div id="main">
            <h1>Demo</h1>

            <!-- PHP code in here -->

            <?php
                echo "test php";
            ?>

            <!--
                ...
                Main code for a table here
            -->
        </div>

    </body>
</html>
2
  • 2
    You are using a server to deliver this, correct? Commented Nov 15, 2010 at 22:48
  • do you mean it prints as plane text? if so make sure PHP is running on your server and hooked in properly Commented Nov 15, 2010 at 22:48

1 Answer 1

10

It sounds like you either don't have PHP installed or you're not using a file extension which invokes the PHP engine - is your file called Blah.php?

Some things to check:

  • You're serving the file from a web server (not locally)
  • The server has PHP installed
  • PHP is configured to handle the file type you're using (usually .php)
  • creating a new file with just <?php phpinfo(); ?> and serving it should give you lots of information about your PHP install.
  • If you have access to the server, you should be able to run PHP from the command line/shell
Sign up to request clarification or add additional context in comments.

6 Comments

...and are you actually running, and going through, a server? (An http: or https: protocol, not file:.)
ugh. hit me with a stick, it was html
@TJ - Good points, I'd edited to add the list by the time I saw your comment but +1 anyway :)
@Glen - when someone answers your question, hit the checkmark next to their answer so they get credit and everyone knows the problem is solved.
@UltimateBrent Thanks for the support and pointing that out but I believe we're still inside the minimum time a Q can be open before an answer is awarded. (At least we were when Glenn commented)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.