---- Rooter v2----In Rooter v2, Rooter is a function instead of a variable. You can now just type rdot('FILENAME'); to locate a file from your selected ROOT. For PHP INCLUDES, you will use rdotinc('FILE');. // ROOTER INCLUDE - Copyright 2012 Yanike Mann (YeoWorks) www.ywcorp.com yeoworks@gmail.com
// USE rdot() for locating anything using ./, ../, etc. e.g. rdot('img/ball.png');[/color]
function rdot($rstr){
$rooterchecker = 0; $rootdot = './'; $rootdot2 = '../'; while($rooterchecker != 2){ if($rooterchecker == 0){ include($rootdot."rooter.php"); if($rootercheck == 1){ echo $rootdot.$rstr; break; } else { $rooterchecker++; } } elseif($rooterchecker == 1){ include($rootdot2."rooter.php"); if($rootercheck == 1){ echo $rootdot2.$rstr; break; } else { $rootdot2 .= '../'; } } }
}
[color="#000000"]// USE rdotinc() FOR PHP INCLUDES e.g. rdotinc('inc/hi.php');[/color]
function rdotinc($rstr){
$rooterchecker = 0; $rootdot = './'; $rootdot2 = '../'; while($rooterchecker != 2){ if($rooterchecker == 0){ include($rootdot."rooter.php"); if($rootercheck == 1){ include($rootdot.$rstr); break; } else { $rooterchecker++; } } elseif($rooterchecker == 1){ include($rootdot2."rooter.php"); if($rootercheck == 1){ include($rootdot2.$rstr); break; } else { $rootdot2 .= '../'; } } }
}
<body>
<p><?php rdotinc('inc/hi.php'); ?><br /><img src="<?php rdot('img/yeoworks.png'); ?>" /></p>
</body>Download RooterA good reason to use Rooter is to easily have one or more root directories. No need to deal with config files. This is just another way to get to a ROOT folder or ROOT folders of your choice.
// rdot() is nba folder and rdot2() wnba folder.
<img src="<?php rdot('img/ball.png'); ?>" />
<img src="<?php rdot2('img/ball.png'); ?>" />
// using rdot() is easier to see and better than writing:
<img src="../../../../../../../nba/img/ball.png" />
<img src="../../../../../../../wnba/img/ball.png" />
// or writing this:
<img src="../../../../nba/img/ball.png" />
<img src="../../../../../../../wnba/img/ball.png" />
Especially if you have to use the right number of dots by hand. rdot() takes care of everything for you.
Edited by yanike, 15 May 2012 - 04:38 PM.