Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get complete current URL using Cakephp Framework in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.33k
    Comment on it

    If you need to print the complete current url you can do following steps.

    1. In the view file code will go like this:

    <?php echo $this->here; ?>
    

    This syntax'll give you the absolute url starting from hostname i.e. /controller/action/params

    2. And if you just need the current URL from hostname. The code will be go like this

    <?php echo Router::url( $this->here, true ); ?> 
    

    This syntax'll give you the full url

    3. The upper two cases are used for cakephp version < 2, If you are using cakephp version 3 then you have write the following code

    $this->Url->build(null, true) 
    

    This syntax'll give you the full url as in cakephp 3.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: