请问href里的内容是什么意思,有错误,但我看不懂

ck_chuyun 2004-08-02 11:07:33
function nav($offset = 0, $this_script = "")
{
........

if ($offset > 0)
{
print "<a href=\ "$this_script?$offset=".($offset-PAGE_LIMIT)."\"><<Previous
Entries</a>   ";
}

if ($offset+PAGE_LIMIT < $total_rows)
{
print "<a href=\ "$this_script?offset=".($offset-PAGE_LIMIT)."\">Next
Entries>></a>   ";
}
}

问几个问题
(1)
运行时提示这句话有错误 ,请问错在哪?

(2)
\ "$this_script?$offset=".($offset-PAGE_LIMIT)."\"

上面的这个\ 有什么用?中间那个问号呢?
请详细的解释这一句话,谢谢

(3)这是用的什么语法格式????
...全文
156 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
surfchen 2004-08-02
  • 打赏
  • 举报
回复
\没有错,\是必须的。
zairwolfc 2004-08-02
  • 打赏
  • 举报
回复
你有改好么?你看看\后面,还是有空格!

晕。
a.php?b=c。后面的b=c就是变量部分了啊。
ck_chuyun 2004-08-02
  • 打赏
  • 举报
回复
还有那个问号????问号是指后面就是变量了啊,这是基本的php常识吧。
问号指后面的变量????PHP哪里说的????
ck_chuyun 2004-08-02
  • 打赏
  • 举报
回复
if ($offset > 0)
{
print "<a href=\ "$this_script?$offset=".($offset-PAGE_LIMIT)."\"><<Previous
Entries</a>   ";
}

if ($offset+PAGE_LIMIT < $total_rows)
{
print "<a href=\ "$this_script?offset=".($offset-PAGE_LIMIT)."\">Next
Entries>></a>   ";
}
改好了,语法是正确了,但只显示了两行记录,上面的语句好像没起效果
zairwolfc 2004-08-02
  • 打赏
  • 举报
回复
晕。原来是同一分钟内而已。csdn的程序真是垃圾,唉。这个计数都做不好。
ck_chuyun 2004-08-02
  • 打赏
  • 举报
回复
语句是通过了,但输出只显示了两个记录
if ($offset > 0)
{
print "<a href=\ "$this_script?$offset=".($offset-PAGE_LIMIT)."\"><<Previous
Entries</a>   ";
}

if ($offset+PAGE_LIMIT < $total_rows)
{
print "<a href=\ "$this_script?offset=".($offset-PAGE_LIMIT)."\">Next
Entries>></a>   ";
}

好像没起作用,怎么回事?
zairwolfc 2004-08-02
  • 打赏
  • 举报
回复
娃哈哈,我跟唠叨也是同时发的贴。
zairwolfc 2004-08-02
  • 打赏
  • 举报
回复
按唠叨说的,把\后面的空格去掉再试试看。
ck_chuyun 2004-08-02
  • 打赏
  • 举报
回复
错误提示
Parse error: parse error, unexpected T_VARIABLE in C:\Apache\Apache2\htdocs\guestbook\header.php on line 214

function nav($offset = 0, $this_script = "")
{
global $PHP_SELF;

if (empty($this_script))
{
$this_script = $PHP_SELF;
}

if (empty($offset))
{
$offset = 0;
}

$result = safe_query("select count(*) from guestbook");

print "<p>\n";

if ($offset > 0)
{
print "<a href=\ "$this_script?$offset=".($offset-PAGE_LIMIT)."\"><<Previous
Entries</a>   ";
}

if ($offset+PAGE_LIMIT < $total_rows)
{
print "<a href=\ "$this_script?offset=".($offset-PAGE_LIMIT)."\">Next
Entries>></a>   ";
}

print "</p>\n";
}

?>
xuzuning 2004-08-02
  • 打赏
  • 举报
回复
1、运行时提示这句话有错误 ,请问错在哪?
请贴出错误信息

2、
print "<a href=\ "$this_script?$offset=".($offset-PAGE_LIMIT)."\"><<Previous
Entries</a>   ";
应写作
print "<a href=\"$this_script?$offset=".($offset-PAGE_LIMIT)."\"><<Previous
Entries</a>   ";
即\ "的\后面没有空格\"表示这个"是“"”字符而不是串分隔符
zairwolfc 2004-08-02
  • 打赏
  • 举报
回复
(1)
运行时提示这句话有错误 ,请问错在哪?

什么提示?

(2)
\ "$this_script?$offset=".($offset-PAGE_LIMIT)."\"

上面的这个\ 有什么用?中间那个问号呢?
请详细的解释这一句话,谢谢


\是转义字符,让"不至于被作为php语法而作为一个字符。问号是指后面就是变量了啊,这是基本的php常识吧。

(3)这是用的什么语法格式????

这是php。
zairwolfc 2004-08-02
  • 打赏
  • 举报
回复
php
ck_chuyun 2004-08-02
  • 打赏
  • 举报
回复
print "<a href=\ "$this_script?$offset=".($offset-PAGE_LIMIT)."\"><<Previous
Entries</a>   ";

当调用这个函数时
nav($offset);
如果用户点击了上面的Previous Entries是不是又再次调用的这个函数,并将改变后的offset值做为参数传递过来
ck_chuyun 2004-08-02
  • 打赏
  • 举报
回复
......
偶在回头好好看看吧!
zairwolfc 2004-08-02
  • 打赏
  • 举报
回复
装个我的论坛啦,保证没问题。呵呵。
ck_chuyun 2004-08-02
  • 打赏
  • 举报
回复
顶一下
ck_chuyun 2004-08-02
  • 打赏
  • 举报
回复
if ($offset > 0)
{
print "<a href=\"$this_script?$offset=".($offset-PAGE_LIMIT)."\"><<Previous
Entries</a>   ";
}

if ($offset+PAGE_LIMIT < $total_rows)
{
print "<a href=\"$this_script?offset=".($offset-PAGE_LIMIT)."\">Next
Entries>></a>   ";
}

改过了,刚才贴的没改而已
不过好像没起作用,只显示两个记录,没法翻页!!!!!!!!!!!

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧