---
title: "刚刚建的仅2k的可配置的PHP URL 路由 http://code.google.com/p/qserouter/"
author: "vb2005xu"
date: "2012-06-05T12:12:15Z"
tags: ["PHP", "Web", "pathinfo", "router"]
categories: ["编程语言"]
slug: "2k-php-url-http-code-google-com-p-qserouter"
draft: false
lastmod: "2012-06-05T12:45:45Z"
id: 1551707
url: "https://vb2005xu.iteye.com/blog/1551707"
---

```
地址: http://code.google.com/p/qserouter/ 上午刚刚建的 :-)


<?php
require 'router.php';

function dump($vars, $label = '', $return = false)
{
    if (ini_get('html_errors')) {
        $content = "<pre>\n";
        if ($label != '') {
            $content .= "<strong>{$label} :</strong>\n";
        }
        $content .= htmlspecialchars(print_r($vars, true));
        $content .= "\n</pre>\n";
    } else {
        $content = $label . " :\n" . print_r($vars, true);
    }
    if ($return) { return $content; }
    echo $content;
    return null;
}

$routes = new Router(require('mapping.php'));

$testarr = array(
	'/',
	'/abc',
	'/abc/d',
	'/books/13',
	'/books/13/java',
	'/admin',
	'/admin/',
	'/admin/abc',
	'/admin/abc/d',
);

foreach ($testarr as $item){
	dump($routes->filter($_GET,$item),$item);	
}



?>
```