Reply to Re: Very newbie question (including other php files)

Your name:

Reply:


Posted by Dan on 11/10/05 15:22

Unfortunately it still doesn't work. I've put a cut-down example of this on my website.

The source code is here ...

www.dracan.co.uk/index_test_php.txt
www.dracan.co.uk/header_test_php.txt

and the actual pages are here ...

www.dracan.co.uk/index_test.php
www.dracan.co.uk/header_test.php

I'm sure it must be something simple, but I can't for the life of me see what it is. Then again, I am extremely new to php.

Thanks for your help with this,
Regards,
Dan.




"Hilarion" <hilarion@SPAM.op.SMIECI.pl> wrote in message news:dkvb8l$de8$1@news.onet.pl...
> > If I've got one file called header.php that contains the following code ...
> >
> > <html>
> > <head>
> > <title><?php echo "$title_string";?></title>
>
> You do not need quotes around variable. The instruction should
> look like this:
> echo $title_string;
> or even:
> echo htmlspecialchars( $title_string );
>
> > </head>
> >
> >
> > and I've got index.php that contains the following code ...
> >
> > <?php $title_string = "My Title String"; ?>
> > <?php include "header.php"; ?>
>
> You do not need to use two PHP sections. You can join the
> code into one section for example like this (I used single
> quotes because they do not evaluate special chars which
> makes using "$" sign and quotes in those easier):
>
> <?php
> $title_string = 'My Title String';
> include 'header.php';
> ?>
>
> > Main body contents<br>
> > </html>
> >
> > Why is the $title_string variable empty (or undefined) in header.php?
> > Basically, my actual header.php is a lot bigger, and I want
> > all my webpages to include this header, but specifying different options
> > - ie. the title string, and a few others.
>
> This example above should work (even with those quotes around variable
> in the header file). Have you checked if this simple example works on your
> PHP server? If not, then check it. If this one works, and your actual code
> does not, then you have some error in the actual code. We'd have to see it
> to tell what is wrong with it.
>
>
> Hilarion

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация