简体   繁体   English

href动态生成的链接不适用于php。 打印但不起作用

[英]href dynamic generation of link not working with php. prints but doesnt work

I am developing an API call with PHP for FreshDesk and would love some insight. 我正在使用PHP为FreshDesk开发API调用,希望能获得一些见解。 I am trying to page the results of the JSON call, and have been successful so far. 我正在尝试分页JSON调用的结果,到目前为止已经成功。 The problem is that my direct links are working but the dynamic ones aren't. 问题是我的直接链接有效,但动态链接无效。

I have tried all kinds of order, casting, type changes, and other tweaks but to no avail. 我尝试了各种顺序,转换,类型更改和其他调整,但均无济于事。 Plus the company's programmer is not even around to help... Here is an excerpt of the code.. more on github. 再加上公司的程序员甚至都没有帮助。这是代码的摘录。

class MyPaginator {
  public $tickets;
  public $wantedStr;
  public $pageNum;

  function __construct($number) {
    $this->$pageNum = $number;
    $this->$wantedStr = $addr . $this->$pageNum;
  }
}
function getPageDecision() {
  $selected = parse_url(curPageURL())['query'];
  if (empty($selected)) {
     $selected = '1';
  } else {
     $selected = str_replace('page=', '', $selected);
  }
 return $selected;
}

$paginator = new MyPaginator(getPageDecision());

$previousPage = ((int)$paginator->$pageNum) - 1;
$nextPage = ((int)$paginator->$pageNum) + 1;

function showPageMenu(){
echo '<br /><div class="pagination">
 <a href="http://tickets.cloudlink.biz/?page='.strval($previousPage).'">&laquo;</a>
 <a href="http://tickets.cloudlink.biz/?page=1"'.activeClass('1').'>1</a>
 <a href="http://tickets.cloudlink.biz/?page=2"'.activeClass('2').'>2</a>
 <a href="http://tickets.cloudlink.biz/?page=3"'.activeClass('3').'>3</a>
 <a href="http://tickets.cloudlink.biz/?page=4"'.activeClass('4').'>4</a>
 <a href="http://tickets.cloudlink.biz/?page=5"'.activeClass('5').'>5</a>
 <a href="http://tickets.cloudlink.biz/?page=6"'.activeClass('6').'>6</a>
 <a href="http://tickets.cloudlink.biz/?page='.strval($nextPage).'">&raquo; 
</a>
</div>';
}

I expect the result of clicking the forward or backward buttons to lead me to /?page= dynamically because the number ones are working..... Thanks in advance! 我希望单击前进或后退按钮的结果会使我动态进入/?page =,因为数字在起作用.....预先感谢!

Problem was not using the global keyword for referencing the correct scope for the function. 问题不是使用全局关键字来引用该函数的正确范围。 Problem is solved. 问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM