|
Posted by Morlaath on 08/20/07 01:10
On Aug 19, 8:04 pm, Galat...@gmail.com wrote:
> On Aug 19, 5:05 pm, gordonb.66...@burditt.org (Gordon Burditt) wrote:
>
>
>
> > >How do I have my whole site on one page of PHP and to get to the pages
> > >would be something like
>
> > >domain.com/index.php?page1
> > >domain.com/index.php?page2
>
> > You can get hold of the part of the query after the ? with:
>
> > $_SERVER['QUERY_STRING']
> > but that also includes GET or POST variables, if any, which you'd need
> > to remove. It might be easier to make your URL of the form:
>
> > domain.com/index.php?p=page1
>
> > and retrieve it with $_REQUEST['p'] .
>
> > After you get the value into a variable, you can use something like:
>
> > switch($_REQUEST['p']) {
> > case 'page1': /* code for page 1 goes here */
> > break;
> > case 'page2': /* code for page2 goes here */
> > break;
> > default: /* code for unexpected page goes here */
> > break;
> > }
>
> Here is the code I tried:
>
> <?php
> switch($_REQUEST['p']) {
> case 'page1': echo "page 1"
> break;
> case 'page2': echo "page 2"
> break;
> default: echo "index"
> break;
> }
>
> ?>
>
> I access the code by typing in domain.com/index.php?p=page1
>
> It then returns:
>
> Parse error: syntax error, unexpected T_BREAK, expecting ',' or ';' on
> line 4
It could be because you are missing ; at the end of your echo
statements.
Navigation:
[Reply to this message]
|