Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Variable Question? 1

Status
Not open for further replies.

jouell

MIS
Nov 19, 2002
304
US
Hi.

I have filenames that are similar and I'd like to include them all in on php file like so:

<?php include('meta/index_html2body.php'); ?>
<?php include('content/_index.php'); ?>


This does not work:

<?php $file = 'index'; ?>
<?php include('meta/"$file"_html2body.php'); ?>
<?php include('content/_"$file".php'); ?>

Any pointers? I've look at the concatenation docs, I don't think that's needed here though?

Thanks!
-jouell


 
Actually either concatenation, or correct usage of quotes would be your best bet so:
Code:
<?php $file   = 'index'; ?>
<?php include('meta/[red]' . $file . '[/red]_html2body.php'); ?>
...

or
Code:
<?php $file   = 'index'; ?>
<?php include([red]"[/red]meta/$file _html2body.php[red]"[/red]); ?>
...

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks vacunita

Concatenation worked as you suggested (My attempts had improper syntax):


Works:

<?php $file = 'index'; ?>
<?php include('meta/' . $file . '_html2body.php'); ?>


The other did not but I have a solution now

Thanks!
-Jouell


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top