original_string: public function set_url($url, array $params = null) {
          global $CFG;
  
          if (is_string($url) && strpos($url, 'http') !== 0) {
              if (strpos($url, '/') === 0) {
                  // Add the wwwroot to the relative url.
                  $url = $CFG->wwwroot . $url;
              } else {
                  throw new coding_exception('Invalid parameter $url, has to be full url or in shortened form starting with /.');
              }
          }
  
          $this->_url = new moodle_url($url, $params);
  
          $fullurl = $this->_url->out_omit_querystring();
          if (strpos($fullurl, "$CFG->wwwroot/") !== 0) {
              debugging('Most probably incorrect set_page() url argument, it does not match the wwwroot!');
          }
          $shorturl = str_replace("$CFG->wwwroot/", '', $fullurl);
  
          if (is_null($this->_pagetype)) {
              $this->initialise_default_pagetype($shorturl);
          }
      }
code: public function set_url($url, array $params = null) {
          global $CFG;
  
          if (is_string($url) && strpos($url, 'http') !== 0) {
              if (strpos($url, '/') === 0) {
                  // Add the wwwroot to the relative url.
                  $url = $CFG->wwwroot . $url;
              } else {
                  throw new coding_exception('Invalid parameter $url, has to be full url or in shortened form starting with /.');
              }
          }
  
          $this->_url = new moodle_url($url, $params);
  
          $fullurl = $this->_url->out_omit_querystring();
          if (strpos($fullurl, "$CFG->wwwroot/") !== 0) {
              debugging('Most probably incorrect set_page() url argument, it does not match the wwwroot!');
          }
          $shorturl = str_replace("$CFG->wwwroot/", '', $fullurl);
  
          if (is_null($this->_pagetype)) {
              $this->initialise_default_pagetype($shorturl);
          }
      }
code_tokens: public function set_url ( $ url , array $ params = null ) { global $ CFG ; if ( is_string ( $ url ) && strpos ( $ url , 'http' ) !== 0 ) { if ( strpos ( $ url , '/' ) === 0 ) { // Add the wwwroot to the relative url. $ url = $ CFG -> wwwroot . $ url ; } else { throw new coding_exception ( 'Invalid parameter $url, has to be full url or in shortened form starting with /.' ) ; } } $ this -> _url = new moodle_url ( $ url , $ params ) ; $ fullurl = $ this -> _url -> out_omit_querystring ( ) ; if ( strpos ( $ fullurl , "$CFG->wwwroot/" ) !== 0 ) { debugging ( 'Most probably incorrect set_page() url argument, it does not match the wwwroot!' ) ; } $ shorturl = str_replace ( "$CFG->wwwroot/" , '' , $ fullurl ) ; if ( is_null ( $ this -> _pagetype ) ) { $ this -> initialise_default_pagetype ( $ shorturl ) ; } }
docstring: You should call this method from every page to set the URL that should be used to return to this page.
  
  Used, for example, by the blocks editing UI to know where to return the
  user after an action.
  For example, course/view.php does:
  $id = optional_param('id', 0, PARAM_INT);
  $PAGE->set_url('/course/view.php', array('id' => $id));
  
  @param moodle_url|string $url URL relative to $CFG->wwwroot or {@link moodle_url} instance
  @param array $params parameters to add to the URL
  @throws coding_exception
docstring_tokens: You should call this method from every page to set the URL that should be used to return to this page .