douan7529 2014-04-18 19:15
浏览 9
已采纳

为什么这个阵列不工作?

The array starts here:

public $link = array();

Keys and values are assigned through the following function:

public function build_links(){
        $this->link['career']     =     $_SERVER['PHP_SELF'].'?p_id=13';
        $this->link['news']       =     $_SERVER['PHP_SELF'].'?p_id=14';
    }

The value is used in following way:

<a href="<?php $this->link['news']?>">news</a>

The link should come up with "p_id=14" but its coming with "p_id=1" even though that value was never assigned and the PHP file is not returning any error. I dont know this is happening. Little help here would be highly appreciated. Thanks.

  • 写回答

1条回答 默认 最新

  • dppxp79175 2014-04-18 19:17
    关注

    you missed to echo it, change to:

    <a href="<?php echo $this->link['news']; ?>">news</a>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?