Jump to content

Call to a member function httpUrl() on null when called inside a function?


desbest
 Share

Recommended Posts

When I use the following code I get an error.

<?php
function test(){
    return $page->httpUrl();
    // return $wire->page->httpUrl();
}
$test = test();
echo $test; 

I get this error.

Quote

Error:     Call to a member function httpUrl() on null

How do I fix it? How do I get the current page's url inside a function? The function is being stored on the same template file of the page being displayed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...