0

This code gives an URL for a QR Code, but I'm going to use it on the print version of the page, so I have to (preg_replace) remove 'print/' from the end of the url string, so the URL given, is for the non-print version. Please.

public function getPageUrl() {      
    $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
    return $url;
}

1 Answer 1

1
public function getPageUrl() {
    $url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];

    if (empty($_SERVER['HTTPS'])) {
        $url = str_replace('https://', 'http://', $url);
    }

    return preg_replace('~/print/?$~i', '', $url);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.