Jump to content

Another question about classes...


behrk2

Recommended Posts

Hey guys, so I am refactoring a bunch of php scripts that I wrote and I am adding classes and functions and what not. Everthing is going well, but I am running into the following snag:

 

I have 3 files: run_auto.php, auto_test.php, and run_all.php.

 

run_auto.php is my main file, which contains if statements that read in arguments from the command line (linux), so for example if I run "$php run_auto.php tc_add_column -regression", then run_auto will see that argv[1] exists, and that it is "tc_add_column". It then passes that argv[1] into my second script, auto_test.php. Now, auto_test.php has two require_once statements, both of which require knowing that argv[1], as it is needed in the require path.

 

Here lies my problem: Let's say I run "$php run_auto.php -regression". argv[1], which is passed to auto_test.php, is now not a valid directory name. So, I surround the require_once statements with an if statement, saying if argv[1] != "-regression", then look at these require statements.

 

BUT, auto_test.php contains a call to a function that needs that require statement in place. So, in run_auto.php, if "-regression" is the first argument (argv[1]), then I don't call auto_test.php. I call run_all.php which then feeds the required directory to the require statements in auto_test.php. That won't happen though because run_auto.php won't even run fully because the compiler sees "require_once('auto_test.php') and it seems it "runs through" that script to make sure everything is kosher, even though I am not calling it, and it will see that those require statements don't have a directory.

 

This is probably all very confusing, but if anyone gets a sense of what I mean and has a suggestion, I would appreciate it! Thanks!

Link to comment
https://forums.phpfreaks.com/topic/142137-another-question-about-classes/
Share on other sites

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.