Jump to content

Send variable to specific instance of an include file


webref.eu

Recommended Posts

Hi All

I have the following include file:

<?php include("inc-select-merchants-by-keyphrase.php"); ?>

Currently, I set a $KeyphraseAds variable for it at the top of my php page, to get merchants for the relevant keyphrase, and it displays a table of merchant results.

However, this only allows one table of results on a page, and I would sometimes like to display multiple tables of results, i.e. use the include file more than once, but set a different $KeyphraseAds each time.

Is there a way of setting an include specific variable, maybe within the include statement itself, to allow me to use the same include multiple times on a page but each time displaying different keyphrase results?

I guess what I'm asking is, is there a way to send a variable to a specific instance of a php include?

Many thanks
Link to comment
Share on other sites

nope your have to use a function() then call that function on the page.

warning.

include more then a few times will give you problams always use a function and call that function from a .php page.

so you make the function on a page.php then you incude once that page and use the function as meny time as you need it.
Link to comment
Share on other sites

function();// This is a function.

function me();// This is a function named me.

function var($var);//this is a function named var and got a varable to be used inside the function or outside the function.

return function name()/ / this is used to return a function within it self.

when you want a function to be seen from another page always include() that .php page then call the function() as shown below

good luck.

function.php
[code]
<?php

function date_today($date_today){

$date=date("d-m-y");

echo $date;

}
?>
[/code]

call the function

[code]
<?php
//include the function
include("function.php");

// call the function throw the include.
function date_today($date_today);

?>

[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.