Voting

: max(zero, nine)?
(Example: nine)

The Note You're Voting On

crazyted at crazyted dot com
23 years ago
I have a header that's include()'ed on each of my pages. I then wanted to add a Perl script to that header file (header.php) via the virtual() command.

Since my header is used by documents in my /www folder along with other folders inside that (and inside those), and virtual() seems to take only relative paths, I had to write some code to dynamically get the path to the perl script.

Hope this helps some ppl out:

$cwd = getcwd();
$script_name = "cgi-bin/perl_script.pl";
$count = substr_count($cwd, '/');
$count = $count - 3;
// get rid of extra absolute paths since my directory is /home/user/www

// Add additional path information
for($i = 1; $i <= $count; $i++){
$script_name = "../".$script_name;
}
virtual($script_name);

<< Back to user notes page

To Top