For relative paths you can use __DIR__ directly rather than dirname(__FILE__) (as long as you are using PHP 5.3.0 and above):
require(__DIR__.'/../../dir2/file3.php');
Remember to add the additional forward slash at the beginning of the path within quotes.
See:
- PHP – with require_once/include/require, the path is relative to what?
- PHP – Relative paths “require”