这段代码来自Larry Ullman的PHP AND MySQL for Dynamic Web Sites (second edition) P.244这段代码是分页的代码,前面省略了,不是重点我的问题在第八和第九行,就是这句:
echo '<a href="view_users.php?s=' . ($start - $display) . '&np=' . $num_pages . '&sort=' . $sort .'">Previous</a> '; 这里单引号里面的句点连接的用法谁能给我解释一下?(书上我觉得没讲清楚,给的几个例子也没有牵涉到如此复杂的结合) 把这句换成echo '<a href="view_users.php?s=' ($start - $display) '&np='$num_pages'&sort='$sort'">Previous</a> ';
会有什么区别? 就是在函数的前后去掉连接的句点,我觉得有单引号再加句点似乎多此一举,要加也应该加在外面?
Script Begin: // Make the links to other pages, if necessary.
if ($num_pages > 1) { echo '<br /><p>';
// Determine what page the script is on.
$current_page = ($start/$display) + 1; // If it's not the first page, make a Previous button.
if ($current_page != 1) {
echo '<a href="view_users.php?s=' . ($start - $display) . '&np=' . $num_pages . '&sort=' . $sort .'">Previous</a> ';
} // Make all the numbered pages.
for ($i = 1; $i <= $num_pages; $i++) {
if ($i != $current_page) {
echo '<a href="view_users.php?s=' . (($display * ($i - 1))) . '&np=' . $num_pages . '&sort=' . $sort .'">' . $i . '</a> ';
} else {
echo $i . ' ';
}
} // If it's not the last page, make a Next button.
if ($current_page != $num_pages) {
echo '<a href="view_users.php?s=' . ($start + $display) . '&np=' . $num_pages . '&sort=' . $sort .'">Next</a>';
} echo '</p>';
echo '<a href="view_users.php?s=' . ($start - $display) . '&np=' . $num_pages . '&sort=' . $sort .'">Previous</a> '; 这里单引号里面的句点连接的用法谁能给我解释一下?(书上我觉得没讲清楚,给的几个例子也没有牵涉到如此复杂的结合) 把这句换成echo '<a href="view_users.php?s=' ($start - $display) '&np='$num_pages'&sort='$sort'">Previous</a> ';
会有什么区别? 就是在函数的前后去掉连接的句点,我觉得有单引号再加句点似乎多此一举,要加也应该加在外面?
Script Begin: // Make the links to other pages, if necessary.
if ($num_pages > 1) { echo '<br /><p>';
// Determine what page the script is on.
$current_page = ($start/$display) + 1; // If it's not the first page, make a Previous button.
if ($current_page != 1) {
echo '<a href="view_users.php?s=' . ($start - $display) . '&np=' . $num_pages . '&sort=' . $sort .'">Previous</a> ';
} // Make all the numbered pages.
for ($i = 1; $i <= $num_pages; $i++) {
if ($i != $current_page) {
echo '<a href="view_users.php?s=' . (($display * ($i - 1))) . '&np=' . $num_pages . '&sort=' . $sort .'">' . $i . '</a> ';
} else {
echo $i . ' ';
}
} // If it's not the last page, make a Next button.
if ($current_page != $num_pages) {
echo '<a href="view_users.php?s=' . ($start + $display) . '&np=' . $num_pages . '&sort=' . $sort .'">Next</a>';
} echo '</p>';
解决方案 »
- ajax超时问题
- 如何实现在一个php页面上点击按钮跳转到另外一个php页面时带上文本框的内容做参数
- 关于mysql表的判断
- (顶者有分)有人能提供类似www.taobao.com的软件平台吗?
- 多次使用include() 导致重复定义函数错误
- 问两个初级问题,希望帮忙,明天一定结贴!
- 一个关于LYCOS的免费PHP站点的问题~
- php新手学习
- 使用zend studio 编写php代码时很卡怎么办
- php socket连接客服端与服务器报错 无法连接到服务器
- windows xp2下 apache_2.2.6+php-5.2.6+MySQL-5.0.45+phpMyAdmin-2.11.6+ZendOptimizer-3.3.0a 配置
- PHP站内搜索分页显示
你改成echo ' <a href="view_users.php?s=' ($start - $display) '&np='$num_pages'&sort='$sort'">Previous </a> '; 1是 编译肯定出错
2是 即便是不出错了(大大的假设一下)很有可能使 $符号已经成为真的$了 所有的变量都不好用了,,,