Re: [PHP] Re: Dynamic Titles

[email protected] (Martin Scotta)
Newsgroups php.general
Message-ID <[email protected]>
PHP complains (usually) after the error.

1.
2. for( $i=0; $i<10; ++$i )
3.     echo $i, "\n"   # missing ;
4.
5. unset( $i );

PHP will complain about unexpected T_UNSET at line 5

Why? Because PHP is expecting a anything different to unset.

So, when PHP says that an error was found at line x take a look at line x-1

Mrtn

On Fri, Jun 12, 2009 at 7:44 AM, Peter Ford <[email protected]> wrote:

> David Robley wrote:
> > Austin Caudill wrote:
> >
> >> Hello, im trying to make the CMS system im using more SEO friendly by
> >> giving each page it's own title. Right now, the system assigns all pages
> >> the same general title. I would like to use PHP to discertain which page
> >> is being viewed and in turn, which title should be used.
> >>
> >> I have put in the title tags the variable "$title". As for the PHP im
> >> using, I scripted the following:
> >>
> >> $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
> >> switch ( $url )
> >> {
> >> default:
> >> $title = "Photoshop tutorials, Flash tutorials, and more! Newtuts
> Tutorial
> >> Search"; break;
> >>
> >> case "$config[HTTP_SERVER]help.php" :
> >> $title = "Newtuts Help";
> >> break;
> >> }
> >>
> >> Right now, im getting this error:
> >> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting
> >> T_STRING or T_VARIABLE or T_NUM_STRING in
> >> /home/a7201901/public_html/includes/classes/tutorial.php on line 803
> >>
> >> Can someone please help me with this?
> >>
> >>
> >>
> >> Thanks!
> > I'm guessing that line 803 is
> >
> > $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
> >
> > which is full of mismatched quotes :-) Try any of
> >
> > $url = "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
> > $url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
> > $url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
> >
> > Cheers
>
> Also the line:
>
>  case "$config[HTTP_SERVER]help.php" :
>
> probably won't work very well : should be either
>
>  case $config[HTTP_SERVER].'help.php':
>
> or
>
>  case "{$config[HTTP_SERVER]}help.php":
>
> according to whether you like interpolation in quotes or not.
>
>
> I recommend finding a development environment or editor that does syntax
> highlighting - that would catch all of these problems before you even save
> the file.
>
> --
> Peter Ford                              phone: 01580 893333
> Developer                               fax:   01580 893399
> Justcroft International Ltd., Staplehurst, Kent
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Martin Scotta
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.