I’ll admit, I’m not the most experienced or knowledgeable about PHP, so please bear with me on this.
I reciently moved my website and all it’s little sub-domain friends over to Dreamhost, and am having some issues with a script I wrote. On one of my sub-domains, I have a filein the main folder that is accessed by every other php file in that domain. I did it this way so I didn’t have a lot of repitition in my site, and all I’d have to do to make a directory available for viewing would be to drop the generic index.php file into it. I wouldn’t even have to modify the file to adjust the …/'s so that it could access the right page.
Say the home directory of a sub-domain was in directory /dir. I’ve got my sort.php file in that directory. Now say directory /dir/newDir/myDir was created for some reason, all I’d have to do would be to drop a generic index.php file into that directory, and it’d be able to display everything perfectly, accessing sort.php from /dir easy as pie.
Now, in theory I should be able to just replace the name of the home directory from my old server with the name of the home directory on this new server, but for the life of me, I can’t get it to work.
Maybe I did something wrong here, I don’t know. It took me quite a while to get the kinks worked out of this, and I’d like to not have to reinvent the wheel here.<? $directory_name = getcwd(); //length of home directory to offset the replacement of the string. $offset = strlen("public_html"); //include statement include substr_replace($directory_name, "/sort.php", (strrpos($directory_name, "public_html") + $offset)); ?>
What keeps happening, though, is that the script will work just fine in the main directory as is (obviously with the new home directory put in place of “public_html”), but if I drill down a level in the tree to a folder in that directory, I have to modify the script to get it to work (I have to take out the “+ $offset” from the last line). If I drill down another level, I can’t get it to work at all to save the life of me.