Is it possible to include only a certain group of variables when trying to include variables from another file?
I currently maintain a website for a realtor.
I use a txt file to include all variables for each listing like the following
$price="what ever the price is";
$bedrooms="number of bedrooms";
etc.
I include the txt file into the listing.php I have setup and that creates the page for each lising.
I would like to find a way for the featured homes page (a page that has a small amount of information about each home and a link to the full details (listing.php)
I have tried just including the text file for each listing just befor that listings entry on the featured homes page, and that works. However the text file for each listing contains over 100 variables, I only need to use about 6 of those for each listing on featured homes page. If I include the full text file of every listing on the featured homes page (with more than 60 listings featured on it) the page then loads slower than I think it should.
So what I am asking is :
Is it possible to include only certain information (variables etc) without including the full file?
Is It Possible to Include only certain variables from a php
Moderator: General Moderators
Sure it's possible, but how to do it best depends on your script. You can use a simple if() blocks/conditionals and enclose variable values, so they only get loaded when a condition has been triggered.
pif!
Code: Select all
if ( $type == 1 && $type == 2 )
{
$price = 'what ever the price is';
$bedrooms = 'number of bedrooms';
}
if ( $type == 1 )
{
$pool = 'has a pool, nice';
}
else if ( $type == 2 )
{
$neighbor = 'not very nice, ouch!';
}pif!
Last edited by printf on Sun Jun 18, 2006 6:08 pm, edited 1 time in total.
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida