PKPString::regexp_replace PHP Method

regexp_replace() static public method

See also: http://ca.php.net/manual/en/function.regexp_replace.php
static public regexp_replace ( $pattern, $replacement, $subject, $limit ) : mixed
$pattern string Regular expression
$replacement string String to replace matches in $subject with
$subject string String to apply regular expression to
$limit int Number of replacements to perform, maximum, or -1 for no limit.
return mixed
    static function regexp_replace($pattern, $replacement, $subject, $limit = -1)
    {
        if (PCRE_UTF8 && !self::utf8_compliant($subject)) {
            $subject = self::utf8_bad_strip($subject);
        }
        return preg_replace($pattern . PCRE_UTF8, $replacement, $subject, $limit);
    }

Usage Example

Esempio n. 1
0
 /**
  * Display user login form.
  * Redirect to user index page if user is already validated.
  */
 function index($args, $request)
 {
     $this->setupTemplate($request);
     if (Validation::isLoggedIn()) {
         $this->sendHome($request);
     }
     if (Config::getVar('security', 'force_login_ssl') && $request->getProtocol() != 'https') {
         // Force SSL connections for login
         $request->redirectSSL();
     }
     $sessionManager = SessionManager::getManager();
     $session = $sessionManager->getUserSession();
     $templateMgr = TemplateManager::getManager($request);
     // If the user wasn't expecting a login page, i.e. if they're new to the
     // site and want to submit a paper, it helps to explain why they need to
     // register.
     if ($request->getUserVar('loginMessage')) {
         $templateMgr->assign('loginMessage', $request->getUserVar('loginMessage'));
     }
     $templateMgr->assign('username', $session->getSessionVar('username'));
     $templateMgr->assign('remember', $request->getUserVar('remember'));
     $templateMgr->assign('source', $request->getUserVar('source'));
     $templateMgr->assign('showRemember', Config::getVar('general', 'session_lifetime') > 0);
     // For force_login_ssl with base_url[...]: make sure SSL used for login form
     $loginUrl = $this->_getLoginUrl($request);
     if (Config::getVar('security', 'force_login_ssl')) {
         $loginUrl = PKPString::regexp_replace('/^http:/', 'https:', $loginUrl);
     }
     $templateMgr->assign('loginUrl', $loginUrl);
     $templateMgr->display('frontend/pages/userLogin.tpl');
 }
All Usage Examples Of PKPString::regexp_replace