Skip to content

Instantly share code, notes, and snippets.

@honzajavorek
Created January 15, 2012 03:42
Show Gist options
  • Save honzajavorek/1614194 to your computer and use it in GitHub Desktop.
Save honzajavorek/1614194 to your computer and use it in GitHub Desktop.
minimální PHP controller
<?php
// tohle zjisteni rootu je docela prasecina, kdysi davno jsem to vymyslel a fungovalo to (dneska uz to za me delaji frameworky)
define('WEB_ROOT', rtrim(str_replace('\\', '/', (dirname($_SERVER['PHP_SELF']) == '/')? '' : dirname($_SERVER['PHP_SELF'])), '/'));
?>
<ul>
<li><a href="<?php echo WEB_ROOT ?>/neco">root/</a></li>
<li><a href="<?php echo WEB_ROOT ?>/neco">root/neco</a></li>
<li><a href="<?php echo WEB_ROOT ?>/neco/dalsiho">root/neco/dalsiho</a></li>
</ul>
<p>Cesta od rootu webu k tomuhle skriptu je: <?php echo WEB_ROOT ?></p>
<p>Parsovat se bude: <?php echo $_SERVER['REQUEST_URI'] ?>, dobre bude asi zacit odriznutim toho rootu: <?php echo preg_replace('#^' . preg_quote(WEB_ROOT) . '#', '', $_SERVER['REQUEST_URI']) ?></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment