I know I am searching using the wrong words because I can't seem to find
a simple answer on this. Here's what I want to do.
helper.inc
<!php
var $fileName2;
class helper {
function funcOne($fileNa me) {
$fp = fopen($fileName ,"r");
$fileName2 = $fileName;
**do stuff with the file**
}
function getFileName() {
return {$fileName2);
}
}
?>
first.php
<html>
<?php
require('helper .inc');
$helper_first = new helper();
$helper_first->funcOne("info. txt");
*****
Lay out page based on info.txt
including link to second.php
*****
?>
</html
second.php
<html>
<?
require('helper .inc');
$helper_second = new helper();
$fileUsedInFirs t = $helper_second->getFileName( );
*****
Lay out page based on info.txt
including link to second.php
*****
?>
</html>
Hope that makes some sense. Basically I will have many pages like
first.php that have the info file (info.txt) I want to use. I want to
be able to grab that information and use it in second.php. I know I
could pass it through the url but now that I have been trying to do this
I want to see what point(s) I am missing. I know the constructor (I
didn't include this in the example)is called each time so the var are
being reset. And there is the whole scope thing but is there a way to
preserve it for later use? It doesn't need to look anything like what I
have laid out.
Thanks,
Will
a simple answer on this. Here's what I want to do.
helper.inc
<!php
var $fileName2;
class helper {
function funcOne($fileNa me) {
$fp = fopen($fileName ,"r");
$fileName2 = $fileName;
**do stuff with the file**
}
function getFileName() {
return {$fileName2);
}
}
?>
first.php
<html>
<?php
require('helper .inc');
$helper_first = new helper();
$helper_first->funcOne("info. txt");
*****
Lay out page based on info.txt
including link to second.php
*****
?>
</html
second.php
<html>
<?
require('helper .inc');
$helper_second = new helper();
$fileUsedInFirs t = $helper_second->getFileName( );
*****
Lay out page based on info.txt
including link to second.php
*****
?>
</html>
Hope that makes some sense. Basically I will have many pages like
first.php that have the info file (info.txt) I want to use. I want to
be able to grab that information and use it in second.php. I know I
could pass it through the url but now that I have been trying to do this
I want to see what point(s) I am missing. I know the constructor (I
didn't include this in the example)is called each time so the var are
being reset. And there is the whole scope thing but is there a way to
preserve it for later use? It doesn't need to look anything like what I
have laid out.
Thanks,
Will
Comment