[PHP] Re: PHP includes

2009-03-10 Thread Gary
Again, thank you for everyone that offered their advice.


Gary gwp...@ptd.net wrote in message 
news:8a.64.51087.33bf3...@pb1.pair.com...
 I'm working on learning php and have been toying with includes, and I am 
 trying to figure the advantages/disadvantages to using them.

 I know that using them eliminates the need to put the files once altered 
 as with a template, however, is that the only advantage.

 My particular concerns are with SEO and if the search engines and the bots 
 can read the page if it is made completely on includes?

 Any and all comments would be appreciated.

 Gary
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP includes

2009-03-10 Thread Gary
Again, thank you for everyone that offered their advice.


Gary gwp...@ptd.net wrote in message 
news:8a.64.51087.33bf3...@pb1.pair.com...
 I'm working on learning php and have been toying with includes, and I am 
 trying to figure the advantages/disadvantages to using them.

 I know that using them eliminates the need to put the files once altered 
 as with a template, however, is that the only advantage.

 My particular concerns are with SEO and if the search engines and the bots 
 can read the page if it is made completely on includes?

 Any and all comments would be appreciated.

 Gary
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: PHP includes

2009-03-10 Thread Mayer, Jonathan


-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 09 March 2009 19:55
To: Mayer, Jonathan
Cc: Gary; php-general@lists.php.net
Subject: RE: [PHP] Re: PHP includes

On Mon, 2009-03-09 at 15:10 +, Mayer, Jonathan wrote:
 Thank you to everybody that replied...but it almost seems it is
making
 extra 
 work.
 
 I can understand using an include for a menu, since they tend to
change
 
 often and it is on every page, but the normal content I am not
 understanding 
 the benefit.  If I have a page that has unique content on it, that is
 to say 
 no other page has this content, why would I want to create a separate
 file 
 to be included on the page, why would I not simple put the content
 directly 
 on the page itself?
 
 What is the best type of file to be used as an include (.txt, .php).
 
 Thanks again for all your help.
 
 There are some circumstances where that could be useful. I don't do it
 often, but one site I made a while ago was based on a standard main
page
 with the content included in. The content pages then had absolutely
 nothing except the unique text, so that redesigns to the site were
made
 easier in the futurem, because only one page needed to be edited. So
the
 entire site was based around a page.php?ID=x with the ID specifying
the
 include required.
 
 Such as an example might be a little out of date now, what with CSS
and
 so forth, but it was useful at the time.
 
 If I am including a file with password details, I usually make it
 something random (.inc, .sec, whatever) and hide it away somewhere
 inacessible
 
 Gary
 Gary gwp...@ptd.net wrote in message 
 news:8a.64.51087.33bf3...@pb1.pair.com...
  I'm working on learning php and have been toying with includes, and
I
 am 
  trying to figure the advantages/disadvantages to using them.
 
  I know that using them eliminates the need to put the files once
 altered 
  as with a template, however, is that the only advantage.
 
  My particular concerns are with SEO and if the search engines and
the
 bots 
  can read the page if it is made completely on includes?
 
  Any and all comments would be appreciated.
 
  Gary
  
 
 
 
 
 
 
Just thought I'd point out that it's recommended against giving non-php
extensions to PHP code pages. Basically, making all of your include
files .inc without the server correctly configured to recognise all .inc
files as PHP files, you are opening yourself up to possible hacks where
people put the URL of your include directly in their browser and view
all your code. Best thing is usually to name files like this:
filename.inc.php or some-such, and not filename.inc. 


Ash
www.ashleysheridan.co.uk


Thanks Ash - that's an excellent point which I'll remember next time I'm
including!




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP includes

2009-03-10 Thread Michael A. Peters

Mayer, Jonathan wrote:





Just thought I'd point out that it's recommended against giving non-php
extensions to PHP code pages. Basically, making all of your include
files .inc without the server correctly configured to recognise all .inc
files as PHP files, you are opening yourself up to possible hacks where
people put the URL of your include directly in their browser and view
all your code.


Easily solveable by keeping your include files in a directory outside 
the web root. IE in a directory apache (or whatever server you use) does 
not serve.


If you have any include files that have sensitive information (IE 
database username/password, the salt/algorithm you use to create a user 
password hash, etc.) then having an include directory outside the web 
root is a must anyway - with or without a .php extension on those files 
(if apache fails to load the php module for whatever reason on a 
restart, those .php files may be sent plain text).


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP includes

2009-03-09 Thread Gary
Thank you to everybody that replied...but it almost seems it is making extra 
work.

I can understand using an include for a menu, since they tend to change 
often and it is on every page, but the normal content I am not understanding 
the benefit.  If I have a page that has unique content on it, that is to say 
no other page has this content, why would I want to create a separate file 
to be included on the page, why would I not simple put the content directly 
on the page itself?

What is the best type of file to be used as an include (.txt, .php).

Thanks again for all your help.

Gary
Gary gwp...@ptd.net wrote in message 
news:8a.64.51087.33bf3...@pb1.pair.com...
 I'm working on learning php and have been toying with includes, and I am 
 trying to figure the advantages/disadvantages to using them.

 I know that using them eliminates the need to put the files once altered 
 as with a template, however, is that the only advantage.

 My particular concerns are with SEO and if the search engines and the bots 
 can read the page if it is made completely on includes?

 Any and all comments would be appreciated.

 Gary
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: PHP includes

2009-03-09 Thread Mayer, Jonathan

Thank you to everybody that replied...but it almost seems it is making
extra 
work.

I can understand using an include for a menu, since they tend to change

often and it is on every page, but the normal content I am not
understanding 
the benefit.  If I have a page that has unique content on it, that is
to say 
no other page has this content, why would I want to create a separate
file 
to be included on the page, why would I not simple put the content
directly 
on the page itself?

What is the best type of file to be used as an include (.txt, .php).

Thanks again for all your help.

There are some circumstances where that could be useful. I don't do it
often, but one site I made a while ago was based on a standard main page
with the content included in. The content pages then had absolutely
nothing except the unique text, so that redesigns to the site were made
easier in the futurem, because only one page needed to be edited. So the
entire site was based around a page.php?ID=x with the ID specifying the
include required.

Such as an example might be a little out of date now, what with CSS and
so forth, but it was useful at the time.

If I am including a file with password details, I usually make it
something random (.inc, .sec, whatever) and hide it away somewhere
inacessible

Gary
Gary gwp...@ptd.net wrote in message 
news:8a.64.51087.33bf3...@pb1.pair.com...
 I'm working on learning php and have been toying with includes, and I
am 
 trying to figure the advantages/disadvantages to using them.

 I know that using them eliminates the need to put the files once
altered 
 as with a template, however, is that the only advantage.

 My particular concerns are with SEO and if the search engines and the
bots 
 can read the page if it is made completely on includes?

 Any and all comments would be appreciated.

 Gary
 






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: PHP includes

2009-03-09 Thread Bob McConnell
From: Gary
 
 Thank you to everybody that replied...but it almost seems it is making
extra 
 work.
 
 I can understand using an include for a menu, since they tend to
change 
 often and it is on every page, but the normal content I am not
understanding 
 the benefit.  If I have a page that has unique content on it, that is
to say 
 no other page has this content, why would I want to create a separate
file 
 to be included on the page, why would I not simple put the content
directly 
 on the page itself?
 
 What is the best type of file to be used as an include (.txt, .php).
 

We include template files for the head block, a banner across the top
of every page, the footer across the bottom, the menu and images in the
left sidebar, and the advertisement banners across the top and bottom.
Even the core section of each page is included from the initial file.
That way we can change the appearance, or modify the links to our
disclaimers and help files just once and every page gets updated. We
also have configuration flags to prevent some of those files from being
included in a specific virtual domain, so our clients can provide their
own templates instead of using ours.

File extensions for includes are up to you. Just make sure your
IDE/Editor know that they are PHP files. We use .lia for the libraries
of functions we use throughout the site. None of our files have .php as
the extension.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP includes

2009-03-09 Thread Sudheer Satyanarayana

Gary wrote:
Thank you to everybody that replied...but it almost seems it is making extra 
work.


I can understand using an include for a menu, since they tend to change 
often and it is on every page, but the normal content I am not understanding 
the benefit.  If I have a page that has unique content on it, that is to say 
no other page has this content, why would I want to create a separate file 
to be included on the page, why would I not simple put the content directly 
on the page itself?
  
There are several advantages of using include. I can't imagine an 
application without include/require/autoload.


I create the database adapter only once per request. I store several 
application configuration items in a config file and load this 
configuration information only once per request. I have one layout for 
the application. Only the content and the menus change. So, I would 
simply include various sections of the web page in relevant positions.

Example:
layout.php
?php
include 'header.php';
include 'menu.php'; // menu.php is also dynamic. menu.php determines 
what to display on the current page.
include 'sidebar.php'; // within sidebar.php I would include 
block_a.php, block_b.php, etc

include 'footer.php';
?

I put the utility functions and classes in a library file. I would 
simply include the library.php and use the functions available in it.


I hope you get the point of using include.

What is the best type of file to be used as an include (.txt, .php).

  


--

With warm regards,
Sudheer. S
Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, 
Personal: http://sudheer.net


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP includes

2009-03-09 Thread Nathan Rixham

Gary wrote:
Thank you to everybody that replied...but it almost seems it is making extra 
work.


I can understand using an include for a menu, since they tend to change 
often and it is on every page, but the normal content I am not understanding 
the benefit.  If I have a page that has unique content on it, that is to say 
no other page has this content, why would I want to create a separate file 
to be included on the page, why would I not simple put the content directly 
on the page itself?


What is the best type of file to be used as an include (.txt, .php).

Thanks again for all your help.

Gary
Gary gwp...@ptd.net wrote in message 
news:8a.64.51087.33bf3...@pb1.pair.com...
I'm working on learning php and have been toying with includes, and I am 
trying to figure the advantages/disadvantages to using them.


I know that using them eliminates the need to put the files once altered 
as with a template, however, is that the only advantage.


My particular concerns are with SEO and if the search engines and the bots 
can read the page if it is made completely on includes?


Any and all comments would be appreciated.

Gary






Hi Gary,

I think this thread is at risk of getting confusing and not addressing 
the problem at its root.


An include is typically used to allow storing reusable code in a file 
all by itself, this could be a settings (config) file, a class, an html 
template or whatever - purpose being of course to keep you all nice and 
organised, with each thing in its place.


Leaving out everything else and focusing only on why we'd use 
include/require in an application, let's take a simple example:


Simple PHP Site with 3 Pages.
1 - / (the homepage)
2 - /?page=about (the about us page)
3 - /?page=contact (the contact us page)

in the above scenario then your index.php could look like this

?php

//set the default page to be home
$page = 'home';

//check if a page has been specified
if( isset($_GET['page']) ) {
  $page = $_GET['page'];
}

if( $page == 'home' )
{
  include 'home.php';
}
elseif ( $page == 'about' )
{
  include 'about.php';
}
else( $page == 'contact' )
{
  include 'contact.php';
}
else
{
  include 'page-not-found.php';
}

?

very simple, but works; now let's expand it a bit.. in a real world 
scenario we probably have a good chunk of script at the top of index.php 
that holds database settings, database connection etc. and in each of 
our pages we probably have much of the html repeated (site header, 
footer, navigation) - we can then abstract these in to there own files 
to keep it all nice and clean.. as such


?php
$page = 'home';
if( isset($_GET['page']) ) {
  $page = $_GET['page'];
}

// get site  database settings
require 'config.php';

// get our database class
require 'classes/class.database.php';

// start out database
$database = new DatabaseClass($settings_from_config);

// load the site header
include 'templates/header.php';

// load the content for the requested page
if( $page == 'home' )
{
  include 'content/home.php';
}
elseif ( $page == 'about' )
{
  include 'content/about.php';
}
else( $page == 'contact' )
{
  include 'content/contact.php';
}
else
{
  include 'content/page-not-found.php';
}

// load the site footer
include 'templates/footer.php';

?

now everything is in its rightful place and we have lots of easy files 
to work with, for example now you can let a designer work on the 
about.php page knowing that they won't be able to break the whole 
application, as it's just a bit of html content.


also, you can now change the header image in one file 
(templates/header.php) and the whole site will update.


most PHP websites are simply far more complex versions of the above, 
look complicated but the principals are the same.


now the only thing I didn't cover is which to use.. it's often the case 
that require_once and include_once should be used over include and 
require; because in most cases (certainly with classes) you just want to 
ensure the code is available. both of the _once statements will only 
load the file if it hasn't been already, thus ensuring no errors such as 
class already defined because it's already been included!


On the other hand if the code in the file has been designed to be used 
many times on a page then include would be the better choice - a 
really stupid example but consider a file containing a fancy horizontal 
bar; you may want to include this many times on a page.


Finally, require and require_once will kill the script with an error if 
the file isn't found, whereas include will throw an error and simply 
keep on going if the files isn't found.


Think that covers everything in the scope of this :)

Regards!

Nathan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP includes

2009-03-09 Thread Nathan Rixham

Gary wrote:
Thank you to everybody that replied...but it almost seems it is making extra 
work.


What is the best type of file to be used as an include (.txt, .php).



new I forgot something! the best type of file to be used as an include 
differs on a case by case basis.


name the files correctly and forget about dictating in advance, file 
extensions are there so people can easily identify what's in the file - 
and when you have 10,000 files you'll really appreciate this :p


some_code.php
some_html.html
some_text.txt

all of them can be included, and even reading the list you can pretty 
much guess what each contains.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: PHP includes

2009-03-09 Thread Ashley Sheridan
On Mon, 2009-03-09 at 15:10 +, Mayer, Jonathan wrote:
 Thank you to everybody that replied...but it almost seems it is making
 extra 
 work.
 
 I can understand using an include for a menu, since they tend to change
 
 often and it is on every page, but the normal content I am not
 understanding 
 the benefit.  If I have a page that has unique content on it, that is
 to say 
 no other page has this content, why would I want to create a separate
 file 
 to be included on the page, why would I not simple put the content
 directly 
 on the page itself?
 
 What is the best type of file to be used as an include (.txt, .php).
 
 Thanks again for all your help.
 
 There are some circumstances where that could be useful. I don't do it
 often, but one site I made a while ago was based on a standard main page
 with the content included in. The content pages then had absolutely
 nothing except the unique text, so that redesigns to the site were made
 easier in the futurem, because only one page needed to be edited. So the
 entire site was based around a page.php?ID=x with the ID specifying the
 include required.
 
 Such as an example might be a little out of date now, what with CSS and
 so forth, but it was useful at the time.
 
 If I am including a file with password details, I usually make it
 something random (.inc, .sec, whatever) and hide it away somewhere
 inacessible
 
 Gary
 Gary gwp...@ptd.net wrote in message 
 news:8a.64.51087.33bf3...@pb1.pair.com...
  I'm working on learning php and have been toying with includes, and I
 am 
  trying to figure the advantages/disadvantages to using them.
 
  I know that using them eliminates the need to put the files once
 altered 
  as with a template, however, is that the only advantage.
 
  My particular concerns are with SEO and if the search engines and the
 bots 
  can read the page if it is made completely on includes?
 
  Any and all comments would be appreciated.
 
  Gary
  
 
 
 
 
 
 
Just thought I'd point out that it's recommended against giving non-php
extensions to PHP code pages. Basically, making all of your include
files .inc without the server correctly configured to recognise all .inc
files as PHP files, you are opening yourself up to possible hacks where
people put the URL of your include directly in their browser and view
all your code. Best thing is usually to name files like this:
filename.inc.php or some-such, and not filename.inc. 


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP includes

2009-03-09 Thread Nathan Rixham

Ashley Sheridan wrote:

Just thought I'd point out that it's recommended against giving non-php
extensions to PHP code pages. Basically, making all of your include
files .inc without the server correctly configured to recognise all .inc
files as PHP files, you are opening yourself up to possible hacks where
people put the URL of your include directly in their browser and view
all your code. Best thing is usually to name files like this:
filename.inc.php or some-such, and not filename.inc. 



v well said - one thing you never want is your source showing!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP includes

2009-03-09 Thread Larry Garfield
On Monday 09 March 2009 3:07:17 pm Nathan Rixham wrote:
 Ashley Sheridan wrote:
  Just thought I'd point out that it's recommended against giving non-php
  extensions to PHP code pages. Basically, making all of your include
  files .inc without the server correctly configured to recognise all .inc
  files as PHP files, you are opening yourself up to possible hacks where
  people put the URL of your include directly in their browser and view
  all your code. Best thing is usually to name files like this:
  filename.inc.php or some-such, and not filename.inc.

 v well said - one thing you never want is your source showing!

Unless you're working in open source and then the source is showing anyway 
from the original download site.  And if simply knowing your source code is a 
security hole, then you have bad software.

Your config file with passwords and such, sure, keep that locked down tight.  
But don't rely on security through obscurity.

-- 
Larry Garfield
la...@garfieldtech.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP includes

2009-03-09 Thread Ashley Sheridan
On Mon, 2009-03-09 at 15:23 -0500, Larry Garfield wrote:
 On Monday 09 March 2009 3:07:17 pm Nathan Rixham wrote:
  Ashley Sheridan wrote:
   Just thought I'd point out that it's recommended against giving non-php
   extensions to PHP code pages. Basically, making all of your include
   files .inc without the server correctly configured to recognise all .inc
   files as PHP files, you are opening yourself up to possible hacks where
   people put the URL of your include directly in their browser and view
   all your code. Best thing is usually to name files like this:
   filename.inc.php or some-such, and not filename.inc.
 
  v well said - one thing you never want is your source showing!
 
 Unless you're working in open source and then the source is showing anyway 
 from the original download site.  And if simply knowing your source code is a 
 security hole, then you have bad software.
 
 Your config file with passwords and such, sure, keep that locked down tight.  
 But don't rely on security through obscurity.
 
 -- 
 Larry Garfield
 la...@garfieldtech.com
 
I was talking about includes that have things such as database
connection information and other sensitive things. By making it a PHP
file, you prevent the code from being seen, ergo you hide your password,
etc. phpMyAdmin does it this way, using a config.inc.php file for
holding the connection information to each database.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: PHP Includes and Echoes in Head Sections and Search Engines

2004-01-16 Thread Ford, Mike [LSS]
On 15 January 2004 22:39, Luke wrote:

 ? Holy cow, this gets simpler all the time. Pretty soon, there'll be
 ? nothing left on my page but PHP includes and echo functions! ?
 ? Does this cut down on a website's file size? In other
 words, are the php
 ? includes effectively inactive when no one's viewing your main pages,
 ? leaving them empty of the included pages?
 
 Well in a way yes, it wont cut down the transfer bandwitdth,
 but because you
 are reusing the same files over again, this will take up less
 disk space on
 your
 server. But the same amount of data is transferred when a
 user views the
 page (as you can see from view-source)
 
 ? But suppose there's a certain page where I don't want the
 style sheet in
 ? the middle - the one I named MIDDLE. Is there a way to mark
 it in the
 ? include page, then instruct the main page to either not import it or
 ? replace it with nothing ()?
 
 youd have to use a variable, so in the main page do the following
 
 if($pagetoshow == 'withoutmiddle'){
 $includemiddle = FALSE;
 }else{
 $includemiddle = TRUE; //(or false depending)
 }

Euch! Very long-winded and inefficient.  Much better is:

   $includemiddle = $pagetoshow!='withoutmiddle';

 
 and in the include do this:
 
 if($includemiddle == TRUE){

Likewise -- this can be written more efficiently and more readbly as simply:

   if ($includemiddle)

(Since $includemiddle will be TRUE or FALSE, you can use it directly in the
if () -- retrieving its value and  comparing it against TRUE gives TRUE if
$includemiddle is, er, TRUE, and FALSE if it's FALSE, so doing the
comparison just wastes CPU time to reproduce the value you first thought
of.)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: PHP Includes and Echoes (Sorry; read this post firs t!)

2004-01-16 Thread Ford, Mike [LSS]
On 16 January 2004 00:30, Freedomware wrote:

 I should have played with this some more before I posted more
 questions. After fixing an error on the included page, I replaced
 every instance of na/a1 on both pages with a1. That seemed to fix
 everything; the first style sheet comes through, but the second one
 is blocked - 
 and I don't
 see any error messages.
 
 I have a couple more questions, though. First, how do I turn this
 exclude function off on a page where I do NOT want to ban
 style sheet na/a1?
 
 I tried deleting the following on the main page:
 
 if($pagetoshow == 'withouta1'){
  $includea1 = FALSE;
 }else{
  $includeaa1 = TRUE; //(or false depending)
 }
 
 Then I changed TRUE and FALSE in various combinations, but it
 didn't work.

Simple -- if you have a page where you want a1 to be unconditionally included, set the 
variable to TRUE unconditionally:

  $includea1 = TRUE;

Similarly, if you want it to be unconditionally blocked:

  $includea1 = FALSE;

The include file will test the value of $includea1 as before, and include it or not as 
you've specified.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP Includes and Echoes (From the top...)

2004-01-16 Thread Freedomware
Thanks for all the tips. It's getting generally getting clearer, but I'm 
a little confused somewhere.

Can I give you a better explanation of what I'm trying to do, along with 
my latest code?

The pages on this site focus on various nations and states, with lots of 
links like this:

[LOCAL] ../world/na/us/wy/index.php (World/North America/United 
States/Wyoming)

[REMOTE] www.politix.org/world/na/us/wy/

Each page will feature several prominent instances of the name of a 
country or state, which I can facilitate by using 'MyName', such as the 
title (MyName = Canada, or Wyoming), along with several instances of its 
abbreviation, which is used in several URLs and in the top banner; for 
example, this is the top banner for Alaska: img 
src=../images/banners/ak.gif width=200 height=150 alt= /

Below is the entire head section from the main page. Notice that it's 
mostly a series of variable statements ('MyName', 'MyCountry', etc.), 
followed by an included page (head), which is essentially the REAL head 
section.

I inserted one of the functions you suggested - $includea1 = TRUE; - 
after the include, but I'm sure I did it wrong.

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
?php
$myname = 'MyName';
$mynickname = 'MyNickname';
$mycontinent = 'North America';
$mycountry = 'United States';
$mystate = 'MyState';
$postcode = 'wy';
$linkcontinent = '/na';
$linkcountry = '/us';
$linkstate = '/wy';
$periods = '../../../../';
$linkwebring = '/world/na/us/wy/';
include (../../../../includes/head.php);
$includea1 = TRUE;
?
/head

* * * * * * * * * *

And here's the included page:

?php
$todayDate = date(m-d-Y);
echo 'titleFreedomware gt; ' . $statename . '/title';
echo 'meta name=description content=' . $statename . ' versus 
Microsoft /';
echo 'meta name=keywords content=' . $statename . ' versus 
Microsoft /';
echo 'meta name=mssmarttagspreventparsing content=true /';
echo 'meta http-equiv=content-Type content=text/html; 
charset=iso-8859-1 /';
echo 'meta name=author content=David Blomstrom /';
echo 'script src=' . $periods . 'js/swapclass.js 
type=text/javascript/script';
echo 'script src=' . $periods . 'js/ss.js 
type=text/javascript/script';
echo 'script language=JavaScript type=text/JavaScript
!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//--
/script';
echo 'link href=' . $periods . 'css/a1.css rel=stylesheet 
type=text/css /';
if ($includea1) echo 'link href=' . $periods . 'css' . $linkcontinent 
. '/a1.css rel=stylesheet type=text/css /';
echo 'link href=' . $periods . 'css/na/north.css rel=stylesheet 
type=text/css /';
echo 'link href=' . $periods . 'css/themes/peace.css rel=alternate 
stylesheet type=text/css title=Peace /';
echo 'link href=' . $periods . 'css/themes/war.css rel=alternate 
stylesheet type=text/css title=War /';
echo 'link rel=SHORTCUT ICON href=../../../../us/aaa/favicon.ico /'
?

Note that two of my style sheets are named css/a1.css and css/na/a1.css 
(na is short for North America). Maybe I should rename the second a1 to 
avoid confusion, though I'd prefer to tackle it head on and learn how to 
deal with this situation. (Does $includea1 = TRUE; refer to css/a1.css 
or css/na/a1.css?)

So here's what I have at present:

* * * * * * * * * *

The first line denotes style sheet css/a1.css, preceded by . $periods 
., which can be replaced by ../../ or ../../../, depending on the 
folder level:

echo 'link href=' . $periods . 'css/a1.css rel=stylesheet 
type=text/css /';

* * * * * * * * * *

The second line denotes style sheet css/na/a1.css, preceded by if 
($includea1), which I'm probably using incorrectly:

if ($includea1) echo 'link href=' . $periods . 'css' . $linkcontinent 
. '/a1.css rel=stylesheet type=text/css /';

Note, also, that I inserted . $linkcontinent ., which will be replaced 
by na/ (North America) on this particular main page.

In summary, it looks like I need to fix two things:

MAIN PAGE

$linkwebring = '/world/na/us/wy/';
include (../../../../includes/head.php);
$includea1 = TRUE;
?
/head
INCLUDED PAGE

echo 'link href=' . $periods . 'css/a1.css rel=stylesheet 
type=text/css /';
if ($includea1) echo 'link href=' . $periods . 'css' . $linkcontinent 
. '/a1.css rel=stylesheet type=text/css /';
echo 'link href=' . $periods . 'css/na/north.css rel=stylesheet 
type=text/css /';

* * * * * * * * * *

I hope that isn't too confusing. It's actually becoming a lot clearer 
for me; I'm just temporarily confused.

Thanks!

* * * * * * * * * *

I wrote,

 ? Holy cow, this gets simpler all the time.

 ? But suppose there's a certain page where I don't want the
 style sheet in
 ? the middle - the one I named MIDDLE. Is there a way to mark
 it in the
 ? include page, then instruct the main page to either not import it or
 ? replace it with nothing ()?
On 15 January 2004 22:39, Luke wrote:

RE: [PHP] Re: PHP Includes and Echoes (From the top...)

2004-01-16 Thread Ford, Mike [LSS]
On 16 January 2004 13:54, Freedomware wrote:

 Thanks for all the tips. It's getting generally getting
 clearer, but I'm
 a little confused somewhere.

[SNIP] 

 I inserted one of the functions you suggested - $includea1 = TRUE; -
 after the include, but I'm sure I did it wrong.

Just like before -- put it *before* the include, otherwise the included file
won't see it.

[SNIP]

 //--
 /script';
 echo 'link href=' . $periods . 'css/a1.css rel=stylesheet
 type=text/css /'; if ($includea1) echo 'link href=' . $periods .
 'css' . $linkcontinent . '/a1.css rel=stylesheet type=text/css
 /'; 
 echo 'link href=' . $periods . 'css/na/north.css rel=stylesheet
 type=text/css /'; echo 'link href=' . $periods .
 'css/themes/peace.css rel=alternate stylesheet type=text/css
 title=Peace /'; 
 echo 'link href=' . $periods . 'css/themes/war.css rel=alternate
 stylesheet type=text/css title=War /';
 echo 'link rel=SHORTCUT ICON
 href=../../../../us/aaa/favicon.ico /'
  
 
 Note that two of my style sheets are named css/a1.css and
 css/na/a1.css (na is short for North America). Maybe I should rename
 the 
 second a1 to
 avoid confusion, though I'd prefer to tackle it head on and
 learn how to
 deal with this situation. (Does $includea1 = TRUE; refer to css/a1.css
 or css/na/a1.css?)

Well, which one is controlled by the if ($includea1) test?

 
 So here's what I have at present:
 

Apart from the above points, looks ok for what you're trying to do.  Keep
plugging away and you'll get there -- a couple of years ago I was a complete
PHP beginner (although an experienced programmer), and now I have several
thousand lines of code in production use!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP Includes and Echoes in Head Sections and Search Engines

2004-01-15 Thread Luke
hi

Very simple problems, good to see ur getting the hang of it :)
the first is, you have defined your variables after you include the page, so
that the echo is outputting a blank variable...

so instead of:

?php include (../../../../includes/state/head.php); ?
meta name=mssmarttagspreventparsing content=true /
?php include (../../../../includes/javascript.php); ?
?php include (../../../../includes/stylesheets.php); ?
?php
$statename = 'Alaska';
$postcode = 'ak';
$linkcode = 'world/na/us/ak';
?

make it

?php
$statename = 'Alaska';
$postcode = 'ak';
$linkcode = 'world/na/us/ak';
php include (../../../../includes/state/head.php);
echo 'meta name=mssmarttagspreventparsing content=true /';
include (../../../../includes/javascript.php);
include (../../../../includes/stylesheets.php);
\?

i just changed the opening and closing tags a little (you didnt need so
many) but the main change is, now the variables come before the included
file, so that the include file can access those variables too.

echo's will work anywhere inside a ?php tag so, it will always output
something to the screen

no problems with search engines, if you use the meta tags and stuff u
usually use, itll work fine

javascript, stylesheets and stuff... the only thing to remember is all the
stylesheet files, and javascript files are relative to the final page
location, not to the include file location, but other than that its the same
as normal

hope that clears it up a bit :)

-- 
Luke
Freedomware [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I'm having a blast with PHP includes and echo functions; I never dreamed
 they could be so simple and effective. But I have a couple questions
 relating to head sections and search engines.

 Consider the following html code:

 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
 head
 ?php include (../../../../includes/state/head.php); ?
 meta name=mssmarttagspreventparsing content=true /
 ?php include (../../../../includes/javascript.php); ?
 ?php include (../../../../includes/stylesheets.php); ?
 ?php
 $statename = 'Alaska';
 $postcode = 'ak';
 $linkcode = 'world/na/us/ak';
 ?
 /head
 body

 Welcome to ?php echo $statename ?!

 * * * * * * * * * *

 And here's the html code from the include named head.php:

 ?php
 $todayDate = date(m-d-Y);
 ?
 titleFreedomware gt; ?php echo $statename ?/title
 meta name=description content=?php echo $statename ? versus
 Microsoft /
 meta name=keywords content=Alaska, Microsoft, Microshaft, Linux,
 Bill Gates, corporate corruption /

 * * * * * * * * * *

 I discovered that includes will apparently work just about anywhere, but
 echo functions apparently don't work with the title tag and meta tags;
 at least, I can't see the word Alaska in those locations when I click
 View Source in my browser.

 So I wondered if there IS a way to make echo functions work in meta tags.

 Also, do you know if text derived from includes causes any problems with
 search engines? My guess is no, because I can see the included words
 just fine when I click View Source.

 Along similar lines, I wondered if there might be potential pitfalls if
 you import links to style sheets and javascripts as includes. Everything
 seems to work just fine so far.

 Thanks.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP Includes and Echoes in Head Sections and Search Engines

2004-01-15 Thread Freedomware
i just changed the opening and closing tags a little (you didnt need so
many) but the main change is, now the variables come before the included
file, so that the include file can access those variables too.
Holy cow, this gets simpler all the time. Pretty soon, there'll be 
nothing left on my page but PHP includes and echo functions!

Does this cut down on a website's file size? In other words, are the php 
includes effectively inactive when no one's viewing your main pages, 
leaving them empty of the included pages?

Here's another question. I'm replacing the ../ URL prefixes with the 
echo name $periods, so I can use these includes in pages on several 
levels, such as geobop/one and geobop/one/two, simply replacing $periods 
with ../../ or ../../../.

Below is some code from my include page:

link href=?php echo $periods ?css/a1.css rel=stylesheet 
type=text/css /
link href=?php echo $periods ?css/MIDDLE.css rel=stylesheet 
type=text/css /
link href=?php echo $periods ?css/na/rockies.css rel=stylesheet 
 type=text/css /

But suppose there's a certain page where I don't want the style sheet in 
the middle - the one I named MIDDLE. Is there a way to mark it in the 
include page, then instruct the main page to either not import it or 
replace it with nothing ()?

Thanks.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP Includes and Echoes in Head Sections and Search Engines

2004-01-15 Thread Luke

? Holy cow, this gets simpler all the time. Pretty soon, there'll be
? nothing left on my page but PHP includes and echo functions!
?
? Does this cut down on a website's file size? In other words, are the php
? includes effectively inactive when no one's viewing your main pages,
? leaving them empty of the included pages?

Well in a way yes, it wont cut down the transfer bandwitdth, but because you
are reusing the same files over again, this will take up less disk space on
your
server. But the same amount of data is transferred when a user views the
page (as you can see from view-source)

? But suppose there's a certain page where I don't want the style sheet in
? the middle - the one I named MIDDLE. Is there a way to mark it in the
? include page, then instruct the main page to either not import it or
? replace it with nothing ()?

youd have to use a variable, so in the main page do the following

if($pagetoshow == 'withoutmiddle'){
$includemiddle = FALSE;
}else{
$includemiddle = TRUE; //(or false depending)
}

and in the include do this:

if($includemiddle == TRUE){
echo 'link href=' . $periods . 'css/MIDDLE.css rel=stylesheet
type=text/css /';
}


just a side point, you may be better of doing your html code with echos, as
you have a few variables in there.. eg
?php
echo 'link href=' . $periods . 'css/a1.css rel=stylesheet
type=text/css /';

if($includemiddle == TRUE){
echo 'link href=' . $periods . 'css/MIDDLE.css rel=stylesheet
type=text/css /';
}
echo 'link href=' . $periods . 'css/na/rockies.css rel=stylesheet
type=text/css /';
?

and if you are echoing a variable, quotes around it arent needed

you can just use
echo $variable;
instead of
echo $variable;

Luke

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP Includes and Echoes in Head Sections and Search Engines

2004-01-15 Thread Freedomware
I wrote:

? But suppose there's a certain page where I don't want the style sheet in
? the middle - the one I named MIDDLE. Is there a way to mark it in the
? include page, then instruct the main page to either not import it or
? replace it with nothing ()?


Luke wrote:

youd have to use a variable, so in the main page do the following

if($pagetoshow == 'withoutmiddle'){
$includemiddle = FALSE;
}else{
$includemiddle = TRUE; //(or false depending)
}
and in the include do this:

if($includemiddle == TRUE){
echo 'link href=' . $periods . 'css/MIDDLE.css rel=stylesheet
type=text/css /';
}




I think I just about have it. But I replaced the middle in both our 
examples with the page I'm REALLY trying to exclude - na/a1.

Most pages on my site will have the following two style sheets:

link href=../../../../css/a1.css rel=stylesheet type=text/css /
link href=../../../../css/na/a1.css rel=stylesheet type=text/css  /
But some will only have the first one:

link href=../../../../css/a1.css rel=stylesheet type=text/css /



So I applied your example to the head section of my main page and came 
up with this:

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
?php
$statename = 'Alaska';
$postcode = 'ak';
$linkcode = 'world/na/us/ak';
$periods = '../../../../';
include (../../../../includes/state/head.php);

if($pagetoshow == 'withoutna/a1'){
$includena/a1 = FALSE;
}else{
$includeana/a1 = TRUE; //(or false depending)
}
?



* * * * * * * * * *

And below is all the code from the included page, head.php:

?php
$todayDate = date(m-d-Y);
if($includeana/a1 == TRUE){
echo 'link href=' . $periods . 'css/na/a1.css rel=stylesheet
type=text/css /';
}
echo 'titleFreedomware gt; $statename/title';
echo 'meta name=description content=ZXZX versus Microsoft /';
echo 'script src=' . $periods . 'js/swapclass.js 
type=text/javascript/script';

echo 'link href=' . $periods . 'css/a1.css rel=stylesheet 
type=text/css /';
echo 'link href=' . $periods . 'css/na/a1.css rel=stylesheet 
type=text/css /';
if($includena/a1 == TRUE){
echo 'link href=' . $periods . 'css/na/a1.css rel=stylesheet 
type=text/css /';
}
echo 'link href=' . $periods . 'css/na/rockies.css rel=stylesheet 
type=text/css /';
?

I haven't been able to exclude na/a1 yet, but everything in the included 
page was working right up until about the end, when I did something that 
knocked it out of action.

Also, I got a division by zero error. Is that something that's caused 
by a mistake I made in writing code? I read a couple articles online 
that suggested it's a problem with Apache.

Finally, is there a way to validate php, similar to validating pages 
for html and css?



and if you are echoing a variable, quotes around it arent needed

you can just use
echo $variable;
instead of
echo $variable;
I got a little confused; did I do it right in the example above?

Thanks!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP Includes and Echoes in Head Sections and Search Engines

2004-01-15 Thread Freedomware
Oops, I spotted some big errors in my included page already. Here's the 
new page:

?php
$todayDate = date(m-d-Y);
echo 'titleFreedomware gt; $statename/title';
echo 'meta name=description content=ZXZX versus Microsoft /';
echo 'script src=' . $periods . 'js/swapclass.js 
type=text/javascript/script';
echo 'link href=' . $periods . 'css/a1.css rel=stylesheet 
type=text/css /';
if($includena/a1 == TRUE){
echo 'link href=' . $periods . 'css/na/a1.css rel=stylesheet 
type=text/css /';
}
echo 'link href=' . $periods . 'css/na/rockies.css rel=stylesheet 
type=text/css /';
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP Includes and Echoes (Sorry; read this post first!)

2004-01-15 Thread Freedomware
I should have played with this some more before I posted more questions. 
After fixing an error on the included page, I replaced every instance of 
na/a1 on both pages with a1. That seemed to fix everything; the first 
style sheet comes through, but the second one is blocked - and I don't 
see any error messages.

I have a couple more questions, though. First, how do I turn this 
exclude function off on a page where I do NOT want to ban style sheet na/a1?

I tried deleting the following on the main page:

if($pagetoshow == 'withouta1'){
$includea1 = FALSE;
}else{
$includeaa1 = TRUE; //(or false depending)
}
Then I changed TRUE and FALSE in various combinations, but it didn't work.

Next, what am I doing wrong with $statename, in the example below? I 
tried quotes (), single quotes ('') and no quotes at all.

?php
$todayDate = date(m-d-Y);
echo 'titleFreedomware gt; $statename/title';
echo 'meta name=description content=ZXZX versus Microsoft /';
echo 'script src=' . $periods . 'js/swapclass.js 
type=text/javascript/script';



BELOW IS THE FINAL VERSION:

?php
$todayDate = date(m-d-Y);
echo 'titleFreedomware gt; $statename/title';
echo 'meta name=description content=ZXZX versus Microsoft /';
echo 'script src=' . $periods . 'js/swapclass.js
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
?php
$statename = 'Alaska';
$postcode = 'ak';
$linkcode = 'world/na/us/ak';
$periods = '../../../../';
include (../../../../includes/state/head.php);

if($pagetoshow == 'withouta1'){
$includea1 = FALSE;
}else{
$includeaa1 = TRUE; //(or false depending)
}
?
/head


INCLUDED PAGE

?php
$todayDate = date(m-d-Y);
echo 'titleFreedomware gt; $statename/title';
echo 'meta name=description content=ZXZX versus Microsoft /';
echo 'script src=' . $periods . 'js/swapclass.js 
type=text/javascript/script';
echo 'link href=' . $periods . 'css/a1.css rel=stylesheet 
type=text/css /';
if($includea1 == TRUE){
echo 'link href=' . $periods . 'css/na/a1.css rel=stylesheet 
type=text/css /';
}
echo 'link href=' . $periods . 'css/na/rockies.css rel=stylesheet 
type=text/css /';
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP Includes and Echoes (Sorry; read this post first!)

2004-01-15 Thread Freedomware
Sheez, I spotted my error regarding $statename. I changed it to the 
following, and it fixed that problem.

?php
$todayDate = date(m-d-Y);
echo 'titleFreedomware gt; ' . $statename . '/title';
echo 'meta name=description content=ZXZX versus Microsoft /';
echo 'script src=' . $periods . 'js/swapclass.js 
type=text/javascript/script';
echo 'link href=' . $periods . 'css/a1.css rel=stylesheet 
type=text/css /';
if($includea1 == TRUE){
echo 'link href=' . $periods . 'css/na/a1.css rel=stylesheet 
type=text/css /';
}
echo 'link href=' . $periods . 'css/na/rockies.css rel=stylesheet 
type=text/css /';
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php