Reply to Re: multiple files using the same include file

Your name:

Reply:


Posted by Will on 11/05/85 11:17

Oli Filth wrote:
> Will wrote:
>
>>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
>
> ^
> That should be a "?"
>
>
>> var $fileName2;
>
> ^
> The member variable declaration should be inside the class.
>
>
>> class helper {
>>
>> function funcOne($fileName) {
>> $fp = fopen($fileName,"r");
>> $fileName2 = $fileName;
>> **do stuff with the file**
>>
>> }
>>
>> function getFileName() {
>> return {$fileName2);
>
> ^
> You want rounded bracket here, not a curly brace.
>
>
>> }
>> }
>>?>
>>
>>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();
>>
>> $fileUsedInFirst = $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.
>
>
> I don't understand what it is that you're trying to do.
>
> When you run second.php, a completely new instance of the helper class
> is produced, which has no reference to the original one.
>
> If you want to share variables between successive scripts (i.e.
> first.php and second.php), either write to a file, a database, put it
> in the URL, or use a session variable.
>

Sorry for all the bone head typos. You told me what I needed to know.
I think I will use session variables.

Thanks,
Will

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация