Jump to content

Passing information to functions


siwelis

Recommended Posts

 

I'm trying to call the function from page1 while in page 2, passing information to be put where the function is located in Page1. I hope I'm being clear with this. Does anyone know how to write this?

PAGE1.PHP

function Page2Content(){
echo $contentfromPage2;
}

 

PAGE2.PHP

include $_SERVER['DOCUMENT_ROOT'].'/PAGE1.PHP';
Page2Content(){
$contentfromPage2 = $_POST['testpost']." ".$_POST['testpost2'];
}

Link to comment
https://forums.phpfreaks.com/topic/53217-passing-information-to-functions/
Share on other sites

Unless I am missing something, the only way to reference the funcions on a page is to have the include(page) at the beginning of each page.

 

I would do this differently if possible, create a php file that holds all of your functions, and then just include that one file onto each page (include("functions.php")). They are always available then.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.