• 0

Basic PHP page


Question

Hi, I don't know PHP at all. But there are some scripts I've been trying to insert into pages that won't work unless that page is a PHP page. Right now my site is all HTML. So aside from putting a .php extension on the end of a page what else does it need to have to be a very basic PHP page?

Thanks

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

Yep, that's basically all you neeed. the HTML tags are optional, you leave them in only if you want to mix some PHP with the HTML, but you don't need it for a basic PHP page.

Link to comment
Share on other sites

  • 0

Ok... i think there might be some confusion.

First off assuming you're running a php 4.0 server write all the php code that you got with in tags like :

<?

// insert code here

?>

between the <? and ?> is where you php the php - which is a similar code to c++.

but you cannot put html code with in the bounds of <? ?>. you may however put html like so:

/*your page */

<?

//php code blah blah

?>

<html><body>html code</body>

</html>

or you may splice php code into any portion of your html code like

...before

<table>

<tr><td>

<?

//php code

?>

</td></tr>

</table>

...after

that is assuming that the php code outputs information onto your page.

think of php code as something that the server processes before the html code is generated and inserts that into your html code before the internet explorer displays the page.

i hope that helps a bit.

if you want more specific help please post your code.

Link to comment
Share on other sites

  • 0

johnorien I think you got it right. The server I'm on is PHP4. The reason I am getting a parse error is because I just put those tags at the top and bottom of an HTML page with HTML between no php code. I thought it was the other way around where HTML went into PHP and not PHP into HTML. My error.

Thanks for clearing it up.

So for the most part it's a php page if it just has a .php extension? Then if there is any PHP code that goes in it that just gets weaved into the HTML? Do I have that right?

Link to comment
Share on other sites

  • 0
I thought it was the other way around where HTML went into PHP and not PHP into HTML. My error.

...

So for the most part it's a php page if it just has a .php extension? Then if there is any PHP code that goes in it that just gets weaved into the HTML? Do I have that right?

Well, for the most part. But you can do it both ways - there's nothing wrong with creating a php script which outputs html, but doesn't actually have any html tags around it.

For example, the following are two perfectly respectable options:

&lt;head&gt;
&lt;title&gt;&lt;?php echo "Test";?&gt;&lt;/title&gt;
&lt;/head&gt;

and

&lt;?php
echo "&lt;head&gt;&lt;title&gt;Test&lt;/title&gt;&lt;/head&gt;";
?&gt;

Sorry for the horribly contrived example...

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.