开发者

Fastest way to match uri string

The following code is in the index.php file of my site and runs every time a page on my website is queried. Both of these requires execute there own respective 404 error pages so dont worry about that. What is the most performance efficient way of doing this within php?

$cache = $_SERVER['REQUEST_URI'];

if(preg_match('/^\/blog/',$cache) || preg_match('/^\/portfolio/',$cache)){
  define('WP_USE_THEMES', true);
  // Loads the WordPress Environment and Template
开发者_StackOverflow社区  require('./wordpress/wp-blog-header.php'); 
}else{
  // Load codeigniter
  require('./codeigniter/index.php');
}


$cache = $_SERVER['REQUEST_URI'];

if (0 === strpos($cache, '/blog/') ||
    0 === strpos($cache, '/portfolio/'))
{
    define('WP_USE_THEMES', true);
    require('./wordpress/wp-blog-header.php'); 
}
    else
{
    require('./codeigniter/index.php');
}

No Regex needed and it is super fast.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜