-1

这是一个幼稚的问题,但我不知道如何解决它。我在 php 代码中使用 html 代码。它工作正常。但是当我在那个 html 代码中使用 php 代码时,它会显示错误。我的代码是->

$config['full_tag_open'] = '<div class="pagination"> <span class="page_no">Page 1 of 30</span> <ul class="pag_list">';

它工作正常,但我想在此使用 php 代码代替第 1 页,共 30 页。像这样->

  $config['uri_segment'] =4;

 $config['full_tag_open'] = '<div class="pagination"> <span class="page_no">Page ."$config['uri_segment']". of 30</span> <ul class="pag_list">';

请帮帮我。提前致谢。

4

2 回答 2

2

PHP 代码位于字符串中,并被视为字符串。

将其更改为:

 $config['uri_segment'] = 4;

 $config['full_tag_open'] = 
    '<div class="pagination"> <span class="page_no">Page '.
    $config['uri_segment'].
    ' of 30</span> <ul class="pag_list">';

请注意,为了清楚起见,我将换行符放入。实际上,关闭(和重新打开)单引号和删除周围的双引号可以解决$config['uri_segment']问题。如果您在荧光笔中查看您的代码(甚至在您的问题中),您会看到它是红色的(如字符串)并且未突出显示(如 PHP 代码)。

于 2012-10-31T07:03:40.670 回答
0

你有一个错字......你.的位置不对,而且在". 看起来你在混合你的报价'/"。尝试这个:

$config['full_tag_open'] = '<div class="pagination"> <span class="page_no">Page ' . $config['uri_segment'] . ' of 30</span> <ul class="pag_list">';
于 2012-10-31T07:04:16.780 回答