PHP script loading took over 10 seconds

Posted by Misiur on Stack Overflow See other posts from Stack Overflow or by Misiur
Published on 2010-05-23T17:14:36Z Indexed on 2010/05/23 17:20 UTC
Read the original article Hit count: 331

Filed under:
|
|
|
|

My again. I've promised to not come back today, but I've got another trouble.

http://www.misiur.com/me/ - it took over 10 seconds to load. Whole site code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>{site('title')}</title>
    <link rel="stylesheet" type="text/css" href="{site('themeDir')}/global.css" />
</head>
<body>
    <div id="site">
            <div id="footer">
            <p>Site Managment System {site('version')} by <a href="http://www.misiur.com">Misiur</a>. Copyright &copy; 2010-{$currYear}.</p>            
        </div>
    </div>
</body>

I think the trouble is in this piece of code:

private function replaceFunc($subject)
    {
        foreach($this->func as $t)
        {
            preg_match_all('/\{'.$t.'\([a-zA-Z,\']+\)\}/i', $subject, $res);
            for($j = 0; $j < sizeof($res[0]); $j++)
            {
                preg_match('/\([a-zA-Z,\']+\)/i', $res[0][$j], $match);
                if($match > 0)
                {
                    $prep = explode(", ", substr($match[0], 1, -1));
                    $args = array();
                    for($i = 0; $i < sizeof($prep); $i++)
                    {
                        $args[] = substr($prep[$i], 1, -1);
                    }
                }
                else
                {
                    $args = array();
                }
                $subject = preg_replace('/\{'.$t.preg_quote($match[0]).'\}/i', call_user_func_array($t, $args), $subject);
            }
        }
        return $subject;
    }

It has to find functions from array ($this->func), cut out arguments, and call function with them. I think that I've messed up. Help.

© Stack Overflow or respective owner

Related posts about php

Related posts about regex