开发者

Why is my PHP string being converted to 1?

Ok, so here's the quick rundown. I have a function to generate the page numbers.

This:

<?php
die($ani->e->tmpl->pages("/archive", 1, 15, 1, true));
?>

will output Single Page like expected.

But this:

<?php
$page_numbers = $ani->e->tmpl->pages("/archive", 1, 15, 1, true);
?>
<?= $page_numbers ?>

will output a simple 1 to the page. Why is it getting converted to a 1? I would expect it to store the 'Single Page' string to the page_numbers variable and then output 开发者_JAVA百科it (like an echo) exactly the same.

EDIT: Running a var_dump($page_numbers) returns int(1)...

Here is the entire function in context:

<?php
// other functions...
function show_list() {
    global $ani;
    $page_numbers = $ani->e->tmpl->pages("/archive", 1, 15, 1, true);
    ob_start();
?>
<!-- content:start -->
<?php
    $archive_result = $ani->e->db->build(array("select" => "*", "from" => "animuson_archive", "orderby" => "0-time", "limit" => 15));
    while ($archive = $ani->e->db->fetch($archive_result)) {
?>
<h2><a href="/archive/article/<?= $archive['aid'] ?>/<?= $archive['title_nice'] ?>"><?= $archive['title'] ?></a></h2>
<!-- breaker -->
<?php
    }
?>
<?= var_dump($page_numbers) ?>
<!-- content:stop -->
<?php
    $ani->e->tmpl->process("box", ob_get_clean());
}
// other functions...
?>


$page_numbers is an integer in both examples. Something else is going on. You'll need to post the code of the pages() method. I suspect the ob_start() is doing something weird, since passing integer 1 to die() will never print that 1 (it will exit with return code 1).

PS: Why can't I make a comment like everyone else?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜