you can use $this->getRequest()->getParam('p')
to get page number.
Either you are in .phtml
or in controller
this will work
If it is not working for you then you can try this:
protected $request;
public function __construct(
\Magento\Framework\App\Request\Http $request,
....//rest of parameters here
) {
$this->request = $request;
...//rest of constructor here
}
public function getIddata()
{
// use
$this->request->getParams(); // all params
return $this->request->getParam('id');
}
Edit:
I have used this type of code $this->getRequest()->getParam('p')
in .phtml
before and it worked perfectly for me