Neither doesn't work though.
I've tried.
So I in http://domain1.com I have an index.php file
The index.php file has require_once ("test.php")
No problem.
But when I move test.php to http://domain2.com
I change the require statement to
require_once ("~username2/public_html/test.php")
This is what I got
Warning: main(~username2/public_html/test.php) [function.main]: failed to open stream: No such file or directory in /home/ursername1/public_html/index.php on line 15
Fatal error: main() [function.require]: Failed opening required '~username2/public_html/test.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username1/public_html/index.php on line 15
And yes file ~username2/public_html/test.php exist.
I can ssh, type more ~username2/public_html/test.php and it would work perfectly fine. I also set permission to 777 on the file.